strobealign
strobealign copied to clipboard
Format the codebase with clang-format
Thanks to a suggestion by @telmin, I spent some time on creating a clang-format configuration and (as a test for now) reformatted the codebase with it.
In the Python world, the Black code formatter has become quite popular, and my experience with using it has generally been quite positive because code formatting simply becomes an automated thing that one doesn’t have to think about anymore. In strobealign, I spent some time on formatting code manually, which did not feel very productive. It did however help me form an opinion on which style I would prefer, and I have configured clang-format in such a way as to follow that style. The style is based on the pre-configured clang-format style named "Chromium", and I added a couple of settings to make it more like the style we are already using (4-space indents instead of 2 for example).
For this to work, we would need to enforce the code style. That is, CI would need to fail if the style is not followed. This is a bit of an incovenience because whoever contributes to the code needs to ensure that the formatting is correct.
@psj1997 This would definitely cause conflicts with your work, so I am not suggesting to merge this before we have found a way to rebase your branch without getting a ton of conflicts.
To do
- [x] Add a CI check
- [x] Add a pre-commit configuration. This would automatically reformat code at
git commit
time - [x] Document this in the Contributing section in the README
- [ ] Figure out how to rebase other branches on top of this one
- [ ] Reformat the other open PRs on top of this one