GameDevTecnico / cubos

A still very barebones game engine focused on voxels and data-oriented programming
https://gamedevtecnico.github.io/cubos/
MIT License
82 stars 34 forks source link

`clang-tidy` action suggestions are not formatted correctly #611

Open luishfonseca opened 12 months ago

luishfonseca commented 12 months ago

Problem

Clang-tidy gives suggestions that then fail formatting

Solution

It should respect .clang-format

luishfonseca commented 12 months ago

Sadly this didn't work

RiscadoA commented 12 months ago

This is still a problem, no use closing it @luishfonseca. You should explain why we can't fix it easily right now, maybe someone in the future can do it. We can also redirect people here later. After that just unassign yourself from the issue.

luishfonseca commented 12 months ago

Sure, here's the explanation of why it's not fixed and how to cope with it:

clang-tidy has 3 ways to operate: just warn, try to fix, write fixes to a file.

When it attempts to fix, it can then format the code afterwards. However, in our action, the fixes are stored in a file and the suggested, so the format step can't be used.

Occasionally, clang-tidy will suggest unformatted code, just accepting leads to CI failure. This same problem applies to any code suggested through the GitHub interface.

The solution is to locally amend the erroneous commit without any extra changes, that alone will trigger the pre-commit and format the suggested changes.