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

Enable clang-tidy readability-braces-around-statements check #160

Merged
merged 18 commits into from
Mar 23, 2022

Conversation

skrobinson
Copy link
Contributor

All tests still pass.

Signed-off-by: Sean Robinson [email protected]

All tests still pass.

Signed-off-by: Sean Robinson <[email protected]>
@github-actions
Copy link

github-actions bot commented Feb 7, 2022

✅Static analysis result - no issues found! ✅

operator& should return combined values of the same type, not a new type
(i.e. bool).  This is much more verbose, but easier to reason about
without implied conversion.

Signed-off-by: Sean Robinson <[email protected]>
Enabling this check caught the implicit bool conversion with
default_arguments::operator& fixed in the previous commit.

Signed-off-by: Sean Robinson <[email protected]>
Adds names for integer bases used with details::parse_number.

Signed-off-by: Sean Robinson <[email protected]>
@skrobinson skrobinson force-pushed the wip-tidy branch 3 times, most recently from 55293d0 to 9eb1fe5 Compare February 8, 2022 19:57
Adds names recommended by clang-tidy (e.g. "unused").

Note that clang-tidy v12 appears to detect unnamed parameters in lambdas,
while clang-tidy v13 does not.

Signed-off-by: Sean Robinson <[email protected]>
Following the clang-tidy suggested fix in consume_digits causes compile
failures with MSVC 19.29 in our CI.

Signed-off-by: Sean Robinson <[email protected]>
Also adds a default destructor, as recommended by the check.

Signed-off-by: Sean Robinson <[email protected]>
Surprisingly, no fixes are required in argparse when turning on this suite
of checks.

Signed-off-by: Sean Robinson <[email protected]>
A common pattern in the previous code was goto/return/throw if a condition
is true, else goto/return/throw something different.  The new pattern
uses the fact that the second goto/return/throw is only reachable when the
first goto/return/throw is not called.

Signed-off-by: Sean Robinson <[email protected]>
The two functions previously flagged by this check,
Argument::is_decimal_literal and Argument::validate, fell below the
default Cognitive Complexity threshold as a result of the branch
simplification for the readability-else-after-return check.

Signed-off-by: Sean Robinson <[email protected]>
Also converts most C-style arrays to a std::array onjects.  The check is
disabled for ArgumentParser::parse_args(int, const char *const[]) as this
is a helper function to convert away from a common input format.

Signed-off-by: Sean Robinson <[email protected]>
The "Cpp11" alias is deprecated for Latest (a rolling standard).  For now,
stick to C++17.

Includes end-of-line whitespace removal.

Signed-off-by: Sean Robinson <[email protected]>
Most changes are to better fit within "ColumnLimit: 80".

The change from "T &&... var" to "T &&...var" is caused by
"PointerAlignment: Right".

Member functions chained from add_argument() use ContinuationIndentWidth,
which is set to 4.  Setting ContinuationIndentWidth to 2 causes many
other continuation lines to change.  So, this commit uses the original
value (i.e. 4) as the preferred size.

Signed-off-by: Sean Robinson <[email protected]>
This trait is unused and removing it does not cause any tests to fail.

Signed-off-by: Sean Robinson <[email protected]>
The new naming pattern is CamelCase for structs, except parse_number as a
primarily callable interface.  Trait structs are named Has*Traits
and constexpr variables to the struct template are named Is*.

Signed-off-by: Sean Robinson <[email protected]>
There are no functional changes in this commit.

Signed-off-by: Sean Robinson <[email protected]>
@skrobinson skrobinson marked this pull request as ready for review March 23, 2022 16:01
@skrobinson
Copy link
Contributor Author

@p-ranav

I had hoped #159 could be completed and merged before this PR to reduce the work needed to prepare #159 for inclusion, but I do not want to wait any longer.

So, I'm ready for feedback about changes needed to make this branch acceptable for merge.

@wanjiadenghuo111
Copy link

wanjiadenghuo111 commented Mar 23, 2022 via email

@p-ranav
Copy link
Owner

p-ranav commented Mar 23, 2022

Thanks @skrobinson

I get three warnings. Did you get these as well?

image

Looks like they are coming from:

  • readability-identifier-naming.ConstexprVariableCase = lower_case
  • readability-identifier-naming.StructIgnoredRegexp = "parse_number" doesn't seem to work for me?

@skrobinson
Copy link
Contributor Author

Interesting... What version of clang-tidy are you using?

*IgnoredRegexp suppressions look to have been added in clang-tidy v12, which is the version used by StaticAnalysis. I have not seen these warnings since adding the ignore patterns.

@p-ranav
Copy link
Owner

p-ranav commented Mar 23, 2022

I see! The clang-tidy version I have is 10.0.0. That would explain it.

foo:bar$ clang-tidy --version
LLVM (http://llvm.org/):
  LLVM version 10.0.0

  Optimized build.
  Default target: x86_64-pc-linux-gnu
  Host CPU: icelake-client

I have no other concerns. I'll merge this. Thanks!!

@p-ranav p-ranav merged commit cba0a1b into p-ranav:master Mar 23, 2022
@skrobinson skrobinson deleted the wip-tidy branch March 23, 2022 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants