-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
Identifying code quality issues e.g. unnecessary null pointer checks #2616
Comments
@elfring can you prepare a PR with the suggested changes? |
Some of those should be using |
@mikee47 do you want to create a PR with the necessary changes? |
💭 Would you become interested to use a development tool like “clang-tidy” for corresponding source code adjustments? |
Fixed in #2643 |
🤔 I got the impression that other source code adjustments would be more appropriate for some implementation details. |
I'm reopening this issue as it is not yet fully resolved. clang-tidy is undoubtedly useful, especially if it can be integrated into the build system in some way. Whether automated code changes are appropriate is another matter.... Are there any other offline code checking tools we might consider? |
This PR allows static code analysis using clang-tidy, suggested by #2616. Clang has more limited `constexpr` support than GCC so cannot parse some of the FlashString and NanoTime code without modification. However, these changes are only made when `__clang__` is defined and do not affect regular builds with GCC. This PR also includes some basic code fixes which clang identifies. There are a lot more to look at. To try it out, build a project with: ``` make CLANG_TIDY=clang-tidy ``` Add additional parameters like this: ``` make CLANG_TIDY="clang-tidy --fix --fix-errors" ``` Notes: - Don't use `-j` option as clang-tidy output and fixes don't get serialised correctly. - Settings are in the main `.clang-tidy` file. A custom version can be used and passed on the command line. - I've been using clang 17.0.6 https://releases.llvm.org/17.0.1/tools/clang/tools/extra/docs/clang-tidy/index.html - Only source files which haven't been built are inspected. So, to restrict which code gets processed built the entire application then 'clean' the relevant modules before proceeding with clang-tidy. - No object code is generated by clang.
An extra null pointer check is not needed in functions like the following.
The text was updated successfully, but these errors were encountered: