Skip to content

STYLE: clang-format AlignEscapedNewlines Left (for macro definitions)#2790

Merged
N-Dekker merged 1 commit intoInsightSoftwareConsortium:masterfrom
N-Dekker:ClangFormat-AlignEscapedNewlines-Left
Oct 13, 2021
Merged

STYLE: clang-format AlignEscapedNewlines Left (for macro definitions)#2790
N-Dekker merged 1 commit intoInsightSoftwareConsortium:masterfrom
N-Dekker:ClangFormat-AlignEscapedNewlines-Left

Conversation

@N-Dekker
Copy link
Copy Markdown
Contributor

@N-Dekker N-Dekker commented Oct 8, 2021

Aligns escaped (\) newlines as far left as possible, according to
https://clang.llvm.org/docs/ClangFormatStyleOptions.html
Applies especially to macro definitions.

Aims to fix a kwrobot-v1/ghostflow-check-master error at pull request
#2785
"Remove virtual from Get/Set macro definitions", as reported by
Dženan Zukić:

commit 8f26661 creates blob [...] at Modules/Core/Common/include/itkMacro.h
with size 101090 bytes (98.72 KiB) which is greater than the maximum
size 100000 bytes (97.66 KiB). If the file is intended to be
committed, set the hooks-max-size attribute on its path.

Tip of the day: when looking at the diff (Files changed) in GitHub, you may like to switch from "Split" to "Unified" view.

@N-Dekker N-Dekker requested review from dzenanz and hjmjohnson October 8, 2021 15:18
@github-actions github-actions Bot added area:Core Issues affecting the Core module type:Style Style changes: no logic impact (indentation, comments, naming) type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct labels Oct 8, 2021
@N-Dekker N-Dekker force-pushed the ClangFormat-AlignEscapedNewlines-Left branch from 06e69a4 to 1f86caa Compare October 8, 2021 15:41
@github-actions github-actions Bot added area:Bridge Issues affecting the Bridge module area:Filtering Issues affecting the Filtering module area:IO Issues affecting the IO module type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots labels Oct 8, 2021
@N-Dekker N-Dekker changed the title STYLE: clang-format AlignEscapedNewlines Left STYLE: clang-format AlignEscapedNewlines Left (for macro definitions) Oct 8, 2021
Copy link
Copy Markdown
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Do @thewtex @hjmjohnson @blowekamp or @jhlegarreta have objections to this minor style change? Is an update of software guide needed for this?

@N-Dekker
Copy link
Copy Markdown
Contributor Author

N-Dekker commented Oct 8, 2021

LGTM. Do @thewtex @hjmjohnson @blowekamp or @jhlegarreta have objections to this minor style change? Is an update of software guide needed for this?

Thanks @dzenanz With this pull request, "itkMacro.h" would go from 90 KB down to 78 KB 🎉

Update, October 12, 2021: Actually, with this pull request, "itkMacro.h" will go from 90 KB down to 74 KB 🎉🎉🎉

@N-Dekker N-Dekker force-pushed the ClangFormat-AlignEscapedNewlines-Left branch from 1f86caa to e8ddfe0 Compare October 8, 2021 16:11
@github-actions github-actions Bot added area:Numerics Issues affecting the Numerics module area:Registration Issues affecting the Registration module area:Segmentation Issues affecting the Segmentation module area:Video Issues affecting the Video module labels Oct 8, 2021
@N-Dekker N-Dekker force-pushed the ClangFormat-AlignEscapedNewlines-Left branch from e8ddfe0 to caf10ce Compare October 8, 2021 16:37
@N-Dekker
Copy link
Copy Markdown
Contributor Author

N-Dekker commented Oct 8, 2021

Catch-22: clang-format locally adjusted my itkCheckHasFenvtStructMember.cxx

But then KWStyle did not want me to commit, saying:

Modules/Core/Common/CMake/itkCheckHasFenvtStructMember.cxx:0: error: Header mismatch: #include (/*=========================================================================) : Utilities/KWStyle/ITKHeader.h
pre-commit hook failure
-----------------------

KWStyle check failed.

Line numbers in the errors shown refer to the file:
Modules/Core/Common/CMake/itkCheckHasFenvtStructMember.cxx.kws

And then the CI rejects the PR! 😢 Any suggestion?

You see, the itk*.cxx files at Modules/Core/Common/CMake do not have a copyright notice. Should they? KWStyle thinks they should. So it rejects any commit with them. But if they don't pass KWStyle, how did they get into the repo in the first place?!?

Update: Resolved by an extra commit: "STYLE: Fix KWStyle check errors from cxx files Modules/Core/Common/CMake"

@hjmjohnson
Copy link
Copy Markdown
Member

I have a microscopic preference for the historical format, even with the larger file size. I am not strongly opposed the the change, but I just don't care about saving 12kb of spaces.

If this is included, I would ask that the hash be added to .git-blame-ignore-revs .

@N-Dekker N-Dekker force-pushed the ClangFormat-AlignEscapedNewlines-Left branch from caf10ce to 9173644 Compare October 8, 2021 20:17
@N-Dekker N-Dekker marked this pull request as ready for review October 8, 2021 20:20
@N-Dekker N-Dekker force-pushed the ClangFormat-AlignEscapedNewlines-Left branch from 9173644 to a75c092 Compare October 8, 2021 20:42
@dzenanz
Copy link
Copy Markdown
Member

dzenanz commented Oct 11, 2021

Does this PR need rebasing now?

Aligns escaped (`\`) newlines as far left as possible, according to
https://clang.llvm.org/docs/ClangFormatStyleOptions.html
Applies especially to macro definitions.

Aims to fix a kwrobot-v1/ghostflow-check-master error at pull request
InsightSoftwareConsortium#2785
"Remove virtual from Get/Set macro definitions", as reported by
Dženan Zukić:

> commit 8f26661 creates blob [...] at Modules/Core/Common/include/itkMacro.h
> with size 101090 bytes (98.72 KiB) which is greater than the maximum
> size 100000 bytes (97.66 KiB). If the file is intended to be
> committed, set the hooks-max-size attribute on its path.

Manually adjusted the six "clang-format off" sections in itkMacro.h according to
the clang-format preferences.
@N-Dekker N-Dekker force-pushed the ClangFormat-AlignEscapedNewlines-Left branch from a75c092 to e90cc5f Compare October 11, 2021 21:06
@N-Dekker
Copy link
Copy Markdown
Contributor Author

Does this PR need rebasing now?

@dzenanz Indeed... I just did! Took out the Fix KWStyle check errors from cxx files .../CMake commit, for clarity. Thank you for merging that one already 😃

@N-Dekker
Copy link
Copy Markdown
Contributor Author

I have a microscopic preference for the historical format, even with the larger file size. I am not strongly opposed the the change, but I just don't care about saving 12kb of spaces.

Thanks for your feedback, @hjmjohnson. Update: This PR actually even saves 16 KB of spaces from "itkMacros.h" 😺: from 90 down to 74 KB! So it would certainly fix the ghostflow-check error at #2785, which rejects source files > 100000 bytes.

If this is included, I would ask that the hash be added to .git-blame-ignore-revs

OK, although I guess that would make it harder in the future for people to figure out why and when this clang-format option was changed.

@N-Dekker N-Dekker requested a review from jhlegarreta October 13, 2021 09:40
@N-Dekker N-Dekker requested review from blowekamp, hjmjohnson and thewtex and removed request for hjmjohnson October 13, 2021 09:41
@N-Dekker
Copy link
Copy Markdown
Contributor Author

One more approval, please... 😃 As Dženan already said, it's just a minor style change...

@N-Dekker N-Dekker merged commit 7829ef6 into InsightSoftwareConsortium:master Oct 13, 2021
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 13, 2021
hjmjohnson pushed a commit that referenced this pull request Oct 14, 2021
hjmjohnson pushed a commit to hjmjohnson/ITK that referenced this pull request May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Bridge Issues affecting the Bridge module area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:IO Issues affecting the IO module area:Numerics Issues affecting the Numerics module area:Registration Issues affecting the Registration module area:Segmentation Issues affecting the Segmentation module area:Video Issues affecting the Video module type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Style Style changes: no logic impact (indentation, comments, naming) type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants