Replies: 3 comments 4 replies
-
|
It would be a good idea to do this indeed, the current code has the mixture of styles and also inconsistent indentation in various places. There are a few things I don't like about your test config and has some inconsistencies with Jos' style which maybe can be fixed if we look into it in more detail, depending how flexible clang-format is. |
Beta Was this translation helpful? Give feedback.
-
|
After testing only briefly, personally I don't like single-line functions even if they are short, like but prefer to unconditionally format as I like to use hard tabs, and in flintinterface.cc I chose to wrap lines over 100 chars (with my preferred tab width of 3) in things like long function definitions with a single indent. (I understand that the 100 char choice then doesn't work if one uses a wider tab width of course). Currently this clang-format config aligns parameters on the function It is also removing the inner spaces in things like Of course all of these choices are highly subjective, and I am also happy to adjust if we find something that looks nice and is easy to apply consistently everywhere. |
Beta Was this translation helpful? Give feedback.
-
What is the purpose of the trailing space? Currently it is inconsistently present. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, each file in the FORM source code has its own coding style, depending on who wrote it (e.g., take a look at the C++ files). This makes it difficult to add or modify code consistently. If contributors introduce their own styles into parts of the files, the codebase will become increasingly chaotic. (I'm not saying the current codebase isn't chaotic :-) )
To avoid this, it would be nice at some point to introduce a code formatter to free us from all those tedious and error-prone formatting tasks. For example, with
clang-format, the config file (.clang-format) might look like the following (last updated on 26 Sept 2025), which at least partially reproduces Jos's style:Installing and applying
clang-format(with a fixed version) can be easily automated, for example, viapre-committhanks to the wheel, if Python is available.To maintain the foldings that include trailing spaces, a dedicated fixer that wraps
clang-formatis needed.pre-commitallows us to use Python files located in the repository for this purpose.Beta Was this translation helpful? Give feedback.
All reactions