Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format the codebase with clang-format #266

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Format the codebase with clang-format #266

wants to merge 4 commits into from

Conversation

marcelm
Copy link
Collaborator

@marcelm marcelm commented Apr 26, 2023

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

  • Add a CI check
  • Add a pre-commit configuration. This would automatically reformat code at git commit time
  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant