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

[suggestion] Add .clang-format to help fit the existing coding style #835

Closed
wants to merge 2 commits into from

Conversation

Arpafaucon
Copy link
Contributor

@Arpafaucon Arpafaucon commented Jul 17, 2024

While working on #825 I found useful to spin up this config file to be able to fit the existing coding style.

It's not perfect, but I already goes a long way; maybe you'd be interested ?

Known caveats:

I committed 2 files so you can quickly look at the diff and get a sense of how files are affected

@wolfpld
Copy link
Owner

wolfpld commented Jul 18, 2024

How does this work in practice, when you are editing files? Proper code formatting is always a problem and it's good to automate this, but I don't want to be fighting with a system that is "fixing" deliberate side-steps from the established convention, like in the examples you show.

@Arpafaucon
Copy link
Contributor Author

I use VSCode; I don't know how much this applies to other users.

Personnally (and in my company), I hate the "format on save" option of VSCode, because it's acting behind your back.

  • In python source code, we adopted black with its strict & deterministic strategy. I like not having to discuss style issues in PR anymore. If you need to deviate from the formatting (typically when entering big arrays of numbers in a matrix-like format) you can always insert comments to locally disable the reformatting. We enforce this in CI, works well in practice, I think
  • for C++, we haven't yet found a default good enough everywhere. So I encourage to use the "format selection" feature to only reformat the lines thet were just edited. This way, diffs stay small, but we get a tool to fix all the minor style issues and have a overall coherent style. We don't enforce this in CI, and assume devs are mature enough (not always the case, though, but we manage). That's what I would suggest for this repo, at least to start

@wolfpld
Copy link
Owner

wolfpld commented Jul 19, 2024

I have cherry-picked the commit. Formatting is done only on demand, so it's fine.

@wolfpld wolfpld closed this Jul 19, 2024
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.

2 participants