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
STYLE: Consistent formatting and indentation of C++ sources #7603
base: main
Are you sure you want to change the base?
Conversation
53355b9
to
6879424
Compare
QObject::connect(q, | ||
SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)), | ||
this->ModuleFinderButton, | ||
SLOT(setToolButtonStyle(Qt::ToolButtonStyle))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we okay with this type of change ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
Configuration based of Clang v17.0.6 Exceptions identified by visually inspecting the updates after running `pre-commit run clang-format -a` Running pre-commit required to update the pre-commit config applying the following patch: ```diff diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2965afd3d3..8016726ea7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,3 +21,8 @@ repos: hooks: - id: pyupgrade args: [--py39-plus] + +- repo: https://github.com/pre-commit/mirrors-clang-format + rev: "v17.0.6" + hooks: + - id: clang-format ```
Sources updated based on the clang-format configuration introduced in the previous commit.
By adding `clang-format` to the pre-commit configuration, it enables the following: * GitHub Action report: Suggested changes are reported in the error log associated with the pre-commit GitHub Action workflow. * Consolidated local pre-commit checks and updates by running: ``` pip install pre-commit pre-commit run --all-files ```
6879424
to
2a72244
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spot checked and didn't see anything I can't live with.
Thanks @jcfr it looks good! I would not enable I don't have specific suggestion about the penalties, anything reasonable will be fine with me. |
Following today's Slicer weekly meeting1, we decided to delayed the integration. We will first work to incrementally integrate formatting changes using Footnotes |
Thanks @pieper, @cpinter, @lassoan @RafaelPalomar, @jamesobutler and @sjh26 for the review and feedback 🙏 |
Consistent automatic formatting is a great improvement. |
This pull request ensures consistent indentation and formatting of for C++ source files.
It introduces
clang-format
configuration files as well aspre-commit
configuration ensuring that IDE can appropriately format the code and continuous integration workflow can report when improperly formatted code is contributed.Once integrated, this commit will be added to the
.git-blame-ignore-revs
1 file.Open Questions
AlignConsecutiveAssignments
2 totrue
?clang-format
exceptions ?Penalties
Default value for penalties are defined as such4:
Footnotes
https://github.com/Slicer/Slicer/blob/main/.git-blame-ignore-revs ↩
https://clang.llvm.org/docs/ClangFormatStyleOptions.html#alignconsecutiveassignments ↩
https://clang.llvm.org/docs/ClangFormatStyleOptions.html#penaltybreakassignment ↩
https://github.com/llvm/llvm-project/blob/llvmorg-17.0.6/clang/lib/Format/Format.cpp#L1559-L1568 ↩