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

[analyzer] Cppcheck support #3680

Merged
merged 21 commits into from
Aug 19, 2022
Merged

[analyzer] Cppcheck support #3680

merged 21 commits into from
Aug 19, 2022

Conversation

vodorok
Copy link
Collaborator

@vodorok vodorok commented Jun 9, 2022

This commit adds support for the Cppcheck analyzer.

The following two commits are also squashed into this:

  • [test] Add new test cases for Cppcheck support
  • [analyzer] Check version compatibility

This commit is the resurrection of works made by Márton Csordás.
The original pull request #2290 had three more refactoring related change
sets which were omitted in this. Some changes were added in compared to
the original commits:

  • The Cppcheck report converter is used to get the results in the
    result_handler.
  • The hash calculation logic has been uplifted to the latest one.
  • Some small small compatibility changes were added because of the
    changes in the code base.

Co-authored-by: bruntib bruntib@users.noreply.github.com
Co-authored-by: vodorok vodorok@gmail.com

@vodorok
Copy link
Collaborator Author

vodorok commented Jun 9, 2022

Closes #484

@bruntib bruntib added this to the release 6.20.0 milestone Jul 4, 2022
@vodorok vodorok force-pushed the cppcheck_own branch 2 times, most recently from a1203fa to 91c14aa Compare July 26, 2022 02:38
@whisperity whisperity added enhancement 🌟 analyzer 📈 Related to the analyze commands (analysis driver) cppcheck 🐞 CppCheck is a static analysis tool for C++ code labels Aug 4, 2022
csordasmarton and others added 10 commits August 9, 2022 22:25
This commit adds support for the Cppcheck analyzer.

The following two commits are also squashed into this:
* [test] Add new test cases for Cppcheck support
* [analyzer] Check version compatibility

This commit is the resurrection of works made by Márton Csordás.
The original pull request Ericsson#2290 had three more refactoring related change
sets which were omitted in this. Some changes were added in compared to
the original commits:
* The Cppcheck report converter is used to get the results in the
result_handler.
* The hash calculation logic has been uplifted to the latest one.
* Some small small compatibility changes were added because of the
changes in the code base.

Co-authored-by: bruntib <bruntib@users.noreply.github.com>
Co-authored-by: vodorok <vodorok@gmail.com>
This patch is a work in progress, there are debug prints all over the
place inside Codechecker, treat it accordingly. Will be amended, and
split up, when I am back from vacation.

Cppcheck now works in a raw directory instead of directly into the
workspace folder.
Exponential explosion of reports in plist files are now fixed.
Checker disable now works on native levels.
The `--disable <cppcheck_check>` now properly translates to `--suppress
<cppcheck_check> in the cppcheck invocation.
The current run configuration of cppcheck is `--enable=all`.

Added two new input paramaters:
With `cppcheck-addons` extra cppcheck checkers can be specified.
With `cppcheck-libraries` the cppcheck library definitions can be added.

Cppcheck reports have to be "fixed" for Codechecker to be able to
properly interpret them. The actual error message must be added to any
multistep report as a last bug path event.

Cppcheck checkers are prefixed with the `cppcheck-` prefix.
@dkrupp
Copy link
Member

dkrupp commented Aug 16, 2022

you may consider adding this analyzer option to the cppcheck plugin
--max-ctu-depth=N Max depth in whole program analysis. The default value
is 2. A larger value will mean more errors can be found
but also means the analysis will be slower.

analyzer/codechecker_analyzer/analyzers/analyzer_base.py Outdated Show resolved Hide resolved
docs/analyzer/checker_and_analyzer_configuration.md Outdated Show resolved Hide resolved
docs/analyzer/checker_and_analyzer_configuration.md Outdated Show resolved Hide resolved
docs/analyzer/user_guide.md Outdated Show resolved Hide resolved
Comment on lines +155 to +157
output_dir = Path(result_handler.workspace, "cppcheck",
result_handler.buildaction_hash)
output_dir.mkdir(exist_ok=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use os.makedirs instead, so it creates the parent directories, and then the other call might truly be redundant.

Copy link
Member

@dkrupp dkrupp left a comment

Choose a reason for hiding this comment

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

LGTM.

Thansk for the patch!

@whisperity whisperity merged commit a8cb930 into Ericsson:master Aug 19, 2022
@dkrupp dkrupp mentioned this pull request Aug 30, 2022
@balazs-benics-sonarsource

🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer 📈 Related to the analyze commands (analysis driver) cppcheck 🐞 CppCheck is a static analysis tool for C++ code enhancement 🌟
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants