Skip to content
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: Replace integer literals which are cast to bool. #4983

Conversation

hjmjohnson
Copy link
Member

Finds and replaces integer literals which are cast to bool.

cd ${BLDDIR}
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-,modernize-use-bool-literals -header-filter=. -fix

PR Checklist

Finds and replaces integer literals which are cast to bool.

cd ${BLDDIR}
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-bool-literals  -header-filter=.* -fix
@hjmjohnson hjmjohnson added the type:Style Style changes: no logic impact (indentation, comments, naming) label Nov 24, 2024
@hjmjohnson hjmjohnson added this to the ITK 6.0 Beta 1 milestone Nov 24, 2024
@hjmjohnson hjmjohnson self-assigned this Nov 24, 2024
@github-actions github-actions bot added type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Numerics Issues affecting the Numerics module labels Nov 24, 2024
@hjmjohnson
Copy link
Member Author

@N-Dekker After all the headache I caused in the previous big commit, I opted for a smaller commit this time :) .

@@ -92,7 +92,7 @@ itkScalarImageToTextureFeaturesFilterTest(int, char *[])
for (int i = 0; i < 5; ++i)
for (int j = 0; j < 5; j++, ++maskIt)
{
maskIt.Set(bool{ 1 });
Copy link
Contributor

Choose a reason for hiding this comment

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

Approved of course, but what about itk::NumericTraits<bool>::OneValue()? 😺

rescale->SetOutputMaximum(itk::NumericTraits<bool>::OneValue());

Copy link
Contributor

Choose a reason for hiding this comment

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

@hjmjohnson I just "unresolved" because I did not see a "resolution" to my remark on itk::NumericTraits<bool>::OneValue(). What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

That's quite a round-about way to write true. There is no need to overcomplicate things. itk::NumericTraits<bool>::OneValue() exists primarily to ease implementing templated code.

@hjmjohnson hjmjohnson merged commit 2792d9a into InsightSoftwareConsortium:master Nov 25, 2024
17 checks passed
@hjmjohnson hjmjohnson deleted the replace-integer-literal-with-bool branch November 25, 2024 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Numerics Issues affecting the Numerics 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants