-
Notifications
You must be signed in to change notification settings - Fork 443
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
feat: add static checker for cpp with cppcheck #2346
Conversation
Signed-off-by: sakshi-1505 <[email protected]>
@lalitb https://github.com/open-telemetry/opentelemetry-cpp/actions/runs/6446820822/job/17505022142?pr=2346 Looks like we will need to blacklist the |
@lalitb The CI worked & was quite fast all 300+ files in just 4 min! Do we want to exit 0 at the failures for cppcheck? |
@lalitb I have made the action to return error whenever any rule is violated for staticcheck. This may cause check failure in CI, which the team might want to look at. |
Yeah the CI should fail in case of any static check violations in the code. |
If there are only few similar pattern of errors, e.g “ The one definition rule is violated,” error as seen in logs, can we suppress cppcheck rules for those error, and let this CI pass. This will enable merging this PR, and then track those errors separately. |
All the test code should be ignored. I think we need a way to list, say in a separate file, all the directories to include/exclude from cppcheck. |
cmake --build . | ||
chmod +x bin/cppcheck | ||
cd ../../opentelemetry-cpp | ||
../cppcheck/build/bin/cppcheck -ithird_party/ --error-exitcode=1 . |
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.
Should we have this CI similar to that for format
:
opentelemetry-cpp/.github/workflows/ci.yml
Lines 678 to 686 in 11d5d9e
format: | |
name: Format | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: setup | |
run: sudo ./ci/install_format_tools.sh | |
- name: run tests | |
run: ./ci/do_ci.sh format |
- Create script to install a particular version of cppcheck passed as argument.
- And invoke the cppcheck through
./do_ci.sh cppcheck
This will also allow developers to invoke static analysis locally.
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.
And should test_common
also be ignored here?
Acknowledged, let me see if there's a way |
If you plan to create the bash script as suggested here, the script can read all the paths to be ignored from a file, and create cppcheck arguments as |
Signed-off-by: sakshi-1505 <[email protected]>
Hi @sakshi-1505 Please find below some guidance to resolve current issues. The CI fails because:
To fix this, add copyright and license as comments. And yes, it means this file must support comments: a simple Please rename this configuration file to As @lalitb already indicated, the scripts should separate clearly:
For the CI workflow, it should use:
and then
A developer locally will have cppcheck already installed, and will run only the second part. About the cppcheck file format, I think it is simpler to provide full cppcheck options already instead of building them. For example:
|
- name: build and run cppcheck | ||
run: | | ||
cd .. | ||
git clone https://github.com/danmar/cppcheck.git --branch 2.12.x |
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.
Use the checkout
action to checkout the cppcheck repo?
run: | | ||
sudo -E ./ci/setup_cmake.sh | ||
sudo -E ./ci/setup_ci_environment.sh | ||
sudo apt-get -y install cmake |
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.
Should cmake install already handled by ./ci/setup_cmake.sh
2 lines above?
Ping @sakshi-1505 Are you still working on this ? Also, please update the PR branch with a recent main. |
Yes I will get this updated by tonight.
…On Thu, 7 Dec 2023, 10:59 pm Marc Alff, ***@***.***> wrote:
Ping @sakshi-1505 <https://github.com/sakshi-1505>
Are you still working on this ?
Do the code review comments make sense ?
Also, please update the PR branch with a recent main.
—
Reply to this email directly, view it on GitHub
<#2346 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BDCZVU22REVU7B35742WAYDYIH4IPAVCNFSM6AAAAAA5XR4T3KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBVG44DKMJZGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
This PR has been opened for 3 months now. We (opentelemetry-cpp maintainers) have offered comments, suggestions and guidance to move forward. The harsh reality as of time of writing (January 2024) is that not only nothing has changed (I understand this part, we all get busy), there is also (from my perspective) a bigger problem of lack of communication, with complete silence and no reply to comments, instead of engaging into a technical discussion to make progress. I am now closing this PR. Thanks for your interest in opentelemetry-cpp. |
Fixes #2297
Changes
Added staticcheck analysis
CHANGELOG.md
updated for non-trivial changes