-
-
Notifications
You must be signed in to change notification settings - Fork 364
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
Apply clang-format for unified coding-style #1427
base: master
Are you sure you want to change the base?
Conversation
The Ubuntu 20.04 build system has an older version of clang-format which dies not yet support provisind the configuration file name through file:filename
The clang-format-10 included in Ubuntu 20.04 does not support one third of the required confiruation options, so going forward to use version 14 as included in Ubuntu 22.04.
The standard repo is moving too fast...
Hi, I'm not sure about this. |
Anything that makes the code easier to maintain is definitely a plus. @mcallegari would you approve if we used their clang profile? |
The QLC style to be found in the current files differs significantly from the rules to be found at https://code.qt.io/cgit/qt/qt5.git/tree/_clang-format. I'll modify the QLCplus rule set to get as close to the existing code with taking the original QT rules in mind and upload a re-ordered version of the original QT rules here, so they can be compared to the QLCplus configuration. It can then be decided what we want to see (with my current assumption: as few as possible changes to the existing and established code, which will then be consisten). |
So now the pointers are on right-aligned. This creates lines like: The attached file clang-format-code.qt.io.txt can now be diffed to the QLCplus Please note that the check is currently not applied to the following cpp directories because they do not strictly follow the rules in their original fashion:
For a batch update , the unittest.sh can be modified with the
|
@hjtappe sorry but I've got some more things that I would adjust:
|
Hello,
No problem. You can even still decide it that is the way to go or to cancel this and go another way. ;-)
I think that's now the case.
Can you point me to a file where you see a misbehaviour, please? Looking at e.g. engine/src/doc.cpp, it indents according to the preprocessor expression level. Do you refer to that it should always start in the first column?
I think I found the switch.
80 will have a significant breaking impact on code. Other standard configurations use 100 rather than 120. I have set that - please take another look if that could also fit our needs. |
Hey @hjtappe sorry for leaving this behind! Might help me to review this. |
Hello @mcallegari, technically this does not work with the indentation program. It can't be told to apply only one set of rules, as far as I see. I wanted to proceeed with this and some other topics in the previous month, but life became too busy the last months. I think I can address this again next year and will set it to draft until I have made the next step. |
Hello @mcallegari, after some research - it is not possible to adress only the pointers indentation only. For a script solution, the pointer "wildcard" character is used in too many places and need semantics understanding of the character environments. The tools helping in indentation all cannot be configured to fix only the pointers. So let's approach the situation from another side. So I provide the project with a script to help checking single files or directories and also to use for the indentation itself. This way, you (and whoever works to unify the code) can selectively update the code that is currently worked on.
Later integration into unittest.sh and the build workflows is prepared but requires the clang-format is added to the commandline via Github actions permissions through myci-actions/add-deb-repo@11. Does that work for you? |
How about this instead of inventing our own script? |
Today, the coding style check is a manual review process, so I wondered if this could not be done by a static code analysis tool to offload that work from @mcallegari as our maintainer.
I first tried how far we could get with the well-established
indent
program, but style recommendations are too far from the current code and configuration options are not sufficient to get closer.So I shifted to clang-format (version 14 as in Ubuntu 22.04) and came quite close. Nevertheless, the build system would have version 10 which does not support required options and clang-format is currently moving fast, so I fixed that to version 14.
Note that therefore the additional
myci-actions/add-deb-repo@*,
entry needs to be allowed in the actions configuration.I applied two configurations, one for *.cpp and *.h and another one for *.js.
Let me know what you think.