-
-
Notifications
You must be signed in to change notification settings - Fork 713
STYLE: Prefer explicit const designation #5025
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
Merged
thewtex
merged 5 commits into
InsightSoftwareConsortium:master
from
hjmjohnson:instrument-with-const
Dec 11, 2024
Merged
STYLE: Prefer explicit const designation #5025
thewtex
merged 5 commits into
InsightSoftwareConsortium:master
from
hjmjohnson:instrument-with-const
Dec 11, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
Author
e48075b to
0f5134c
Compare
dzenanz
approved these changes
Dec 9, 2024
dzenanz
approved these changes
Dec 9, 2024
610b541 to
f17aa08
Compare
Member
Author
|
The last two commits represent warnings that appear only on Windows/Linux builds. I left them broken out as separate patchsets to help document what warning occurred and show how they were overcome. |
dzenanz
approved these changes
Dec 10, 2024
4495fa0 to
b044168
Compare
b044168 to
eef6d4c
Compare
eef6d4c to
2c66c13
Compare
Implements detection of local variables which could be declared as const but
are not. Declaring variables as const is recommended by many coding
guidelines, such as: ES.25 from the C++ Core Guidelines.
cd ${BLDDIR}
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,misc-const-correctness -header-filter=.* -fix
lambda capture 'n' is not required to be captured for this use [-Wunused-lambda-capture]
Modules\IO\Meta\test\testMetaImage.cxx(154): error C2666: 'MetaImage::SequenceID': 2 overloads have similar conversions Modules\ThirdParty\MetaIO\src\MetaIO\src\metaImage.h(182): note: could be 'void MetaImage::SequenceID(const float *)' Modules\ThirdParty\MetaIO\src\MetaIO\src\metaImage.h(180): note: or 'float MetaImage::SequenceID(int) const' Modules\IO\Meta\test\testMetaImage.cxx(154): note: while trying to match the argument list '(const int)' Modules\IO\Meta\test\testMetaImage.cxx(154): note: note: qualification adjustment (const/volatile) may be causing the ambiguity Modules\IO\Meta\test\testMetaImage.cxx(165): error C2666: 'MetaImage::ElementSize': 3 overloads have similar conversions Modules\ThirdParty\MetaIO\src\MetaIO\src\metaImage.h(201): note: could be 'void MetaImage::ElementSize(const float *)' Modules\ThirdParty\MetaIO\src\MetaIO\src\metaImage.h(199): note: or 'void MetaImage::ElementSize(const double *)' Modules\ThirdParty\MetaIO\src\MetaIO\src\metaImage.h(197): note: or 'double MetaImage::ElementSize(int) const' Modules\IO\Meta\test\testMetaImage.cxx(165): note: while trying to match the argument list '(const int)' Modules\IO\Meta\test\testMetaImage.cxx(165): note: note: qualification adjustment (const/volatile) may be causing the ambiguity
Modules\Filtering\LabelMap\include\itkShapeKeepNObjectsLabelMapFilter.h(156): warning C4269: 'comparator': 'const' automatic data initialized with compiler generated default constructor produces unreliable results
Modules/Core/Common/test/itkImageBufferRangeGTest.cxx: In lambda function:
Modules/Core/Common/test/itkImageBufferRangeGTest.cxx:670:61:
warning: declaration of 'n' shadows a previous local [-Wshadow]
670 | const auto expectedResult = [&r](const difference_type n) {
| ^
Modules/Core/Common/test/itkImageBufferRangeGTest.cxx:667:31:
note: shadowed declaration is here
667 | constexpr difference_type n = 3;
| ^
Modules/Core/Common/test/itkImageBufferRangeGTest.cxx: In lambda function:
2c66c13 to
9683b52
Compare
This was referenced Dec 11, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements detection of local variables which could be declared as const but
are not. Declaring variables as const is recommended by many coding
guidelines, such as: ES.25 from the C++ Core Guidelines.
cd ${BLDDIR}
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-,misc-const-correctness -header-filter=. -fix
PR Checklist