-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Use latest version of cppcheck (2.15.0) to analyze codebase #3283
Conversation
- Run cppcheck on MacOS to use a newer version of cppcheck
- Do not scan third-party libraries (others dir) - Use standard C++17 for checks (defaults to C++20)
…sis of branches. Use --check-level=exhaustive to analyze all branches.)
…des a function in a base class but is identical to the overridden function)
warning: seclang-parser.hh,2116,warning,duplInheritedMember,The struct 'basic_symbol < by_kind >' defines member function with name 'clear' also defined in its parent struct 'by_kind'. warning: seclang-parser.hh,2376,warning,duplInheritedMember,The struct 'basic_symbol < by_kind >' defines member function with name 'type_get' also defined in its parent struct 'by_kind'. warning: seclang-parser.hh,2116,warning,duplInheritedMember,The struct 'basic_symbol < by_state >' defines member function with name 'clear' also defined in its parent struct 'by_state'. warning: seclang-parser.hh,2120,style,constVariableReference,Variable 'yysym' can be declared as reference to const
…stions - The following two warnings were generated after introducing the change to instantiate the DigestImpl template with the address of mbedtls_md5 or mbedtls_sha1: - warning: src/utils/sha1.h,62,error,danglingTemporaryLifetime,Using pointer that is a temporary. - warning: src/utils/sha1.h,60,style,constVariablePointer,Variable 'ret' can be declared as pointer to const - See owasp-modsecurity#3231 (comment)
8b865f3
to
60dad6a
Compare
I added two commits (unrelated to this PR) to address Sonarcloud reports. The first blocked analysis of the commits due to Sonarcloud finding (existing) duplicate code in The set of "new" (between quotes) issues reported by Sonarcloud after these changes are:
|
60dad6a
to
049e436
Compare
- Reported by Sonarcloud
- Reported by Sonarcloud
049e436
to
b0497d9
Compare
Hi @eduar-hte, many thanks for this great PR. Also thanks for adding I have only one question regarding the new inline suppression's: are those there because of the new About SonarCloud: I already sent you an invitation to have an admin role on SonarCloud - haven't you received that? With that you could mark those issues (that you explain every time really accurately) as FP and suppress them. |
Yes, the new version reported some new issues, some of which were addressed with changes to the code as they were correct (see commits related to using the At the same time, the new version also introduced a (limited) number of inaccurate issues, which I had to address by adding the inline suppressions you noticed (those are grouped in commit d053ec6). I understand that while they may add new features and address bugs in newer versions, some of these changes may have introduced inaccurate reports as well. 🤷♂️ I've spent some time today on this PR again to do an experiment and remove all current inline suppressions and check which ones are still reported, because it may be the case that they're no longer necessary. As you can see in a0490bd, I could do away with a few of them, which is nice. Additionally, when reviewing every one that was still reported by
Sorry, I didn't see that. In any case, I'm not sure whether we should remove some of the issues reported by Sonarcloud that I detail in some of the PRs. My goal with that is to document which issues are unrelated to changes in the PR (they currently exist in the codebase and Sonarcloud reports them in the PR because I would group the issues in those lists in at least three groups:
About the first group, I think it would make sense to flag them, but I think it'd be better to do so through a mechanism similar to cppcheck's inline suppressions. I tried to look for that, but I couldn't find it (this Sonarcloud community issue seems to be about that). |
I saw and I though you aligned those because of this reason.
Thanks,
Thanks again. I saw you added some more stuff (removed some inline suppression). Let me know if you finish this PR. |
- This is correct because base class is initialized before members are initialized. - Removes cppcheck suppression by addressing reported issue. - Leverage C++11's 'default member initializer' to initialize m_provider & m_demandsPassword and address Sonarcloud issue.
…as this->m_variables - The name of the local variable would clash with the namespace of the same name, which may have lead cppcheck to think the variable was not used.
a0490bd
to
aca93f5
Compare
Quality Gate passedIssues Measures |
That's right, I did away with a few of the cppcheck inline suppressions, as I ended up explaining in an edit of my previous reply (which I was in the process of writing when the build with the new changes completed so I decided to merge them into the PR and then resume the lengthy reply 😁). PS: I ended up even addressing the new issue Sonarcloud reported and that I mentioned here:
just not to add up to the number of outstanding Sonarcloud issues. I'm now done with this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for the PR again and for the detailed explanations. I'm merging this now. |
what
cppcheck
GitHub workflow to run on the latest version of that tool (2.15.0) for better codebase analysis (more aligned with that of Sonarcloud).cppcheck
version 2.14.2 because that was the last version at the time it was created. However, the GitHub macOS runner will now install 2.15.0 (the latest version), which has been released since then (Aug 31, 2024).cppcheck
configuration to have the analysis be performed using C++17, which is aligned with the build configuration for the project.why
The latest version of
cppcheck
includes improved analysis and address some limitations of the version currently used (2.7.1, from Feb, 2022).For example,
std::string_view
instances are expected to be passed by value (see https://quuxplusone.github.io/blog/2021/11/09/pass-string-view-by-value/), but the older version ofcppcheck
would report a warning incorrectly stating that the argument should be passed by reference instead. This was addressed in danmar/cppcheck#3817notes
The
cppcheck
GitHub workflow now runs on the macOS image (instead of the Ubuntu/Linux image previously used) for two reasons:cppcheck
available, so we needed to manually checkout thecppcheck
repository and compile the tool, which would make the workflow more complex and take more time.cppcheck
build in Ubuntu/Linux would run much slower than the package available on macOS (probably due to some additional build instructions being required to improve performance which I couldn't determine/find).