-
Notifications
You must be signed in to change notification settings - Fork 15
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
Modernize clang-format file #342
base: master
Are you sure you want to change the base?
Conversation
I like that the clangformat file only has the essentials for now, I think it makes it easier for discussion purposes. In the final version, however, we should change it back into a full file. I made the One (potentially) controversial change I've made is
The CI seems to be using clangformat 14. I would vastly prefer 18, because that's what MaMiCo uses, but we can discuss that further. We could also use git hooks to format all new files according to the clangformat, however AFAIK git hooks are not server side. |
|
We agreed on the style and content of the |
@cniethammer @FG-TUM @amartyads |
I just encountered a non-trivial problem with clang-format, which was not mentioned so far: We have the Doxygen documentation including The doxygen style is using Option 1:
Option 2:
Both options require us to go over all the comments. Option 1 is somehow consistent with the current Doxygen block style - but looks IMHO disturbing. Option 2 looks nice but will require us to change the Doxygen block style. I am in favour of Option 2. Note: While I am not fully opposing the idea of a consistent coding style - I am not convinced, that reformating and making this mandatory are worth the effort ... especially since I am starting to look more into this. Sidenote: GitHub code review suggestions will by the way also be affected ... nothing a cmake formater tool will help you with, especially when you use the smartphone app. |
Found another special case: Copyright comments at the beginning of files - we should not mess up institutions and copyright years. |
I'm almost sure we can resolve both of the special cases you mention with |
It could be even uglier. Sometimes, the doxygen codes have no leading We could:
Explanation of point 2: |
What are we actually trying to solve here? Afaik clang-format just enforces a line limit on comments and leaves indent as is. Yes introducing line breaks in xml code can be confusing in documentation but that's what a PR review is for. In my opinion examples like the one liked by @HomesGH are bad and should be formatted anyway instead of preserving. @cniethammer you mentioned code that ends up "in a very messed up way". Please list them (some?) which are unchangeable so we can discuss the actually problematic cases. |
I did not say it is impossible (brought also up a solution I found). I am just trying to look for potential issues and what they will require us to invest in terms of effort for our upcoming one-time update and future maintenance of the code after enforcing this - as well as the setup that will be built around, i.e., the clang-format style as well as related CI, will require work in the future and some maintainer, too. I would not consider myself enough of a specialist in clang-format to do this. I just had a quick look into the io plugins - RDF.h and ADIOSWriter.h are for example such cases. But it's a fair point, that refactoring the comments could prevent some of the trouble. I guess this needs some closer look and experimenting. But nothing to be done in a day - at least for me... |
So I took the two files The code looks a lot better though. My proposal is, instead of scary regex magic spells, we simply turn RDF-noRefl.txt My reasoning is, since we're adding formatting to make code readable, it shouldn't be necessary for comments, since comments are already readable (ideally). I couldn't test for any files where clangformat messes up the copyright info. I can also try to work on a more focused regex that excludes doxygen code blocks and copyright info, if someone could give me an example for the latter. One last thing I tried was to replace So in conclusion, we can add |
Two observations from the files you show:
I'm not really invested in this anymore, so I don't care to how you handle this in the end. My advice would be to bite the bullet and refactor/reformat the whole code base properly including comments, documentation, and licenses. Sure this is some work but in the long term this brings consistency and thus readability. But if none of you want to do that I guess |
Description
As discussed in issue #276 , we want to add a clang-format file to enforce an unified style in ls1.
For this, we have to:
.clang-format
fileCMake
to just run commandmake clang-format
for formatting (this is not working for now, help wanted!)make clang-format
for formattingIf we want to be very fancy, we could do something like in MegaMol.
Resolved Issues
I would recommend that this PR does not apply the formatting to the whole code base in ls1. This should be done in a separate PR for the sake of clarity.