-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[ci] warnings from cppcheck #4539
Comments
471 warnings on I've filtered out only the warnings from the full logs by running the following: cat cppcheck.txt | grep -E '\[[a-zA-Z]+\]$' warnings only (click me)
The full logs are much larger. Here's a snippet of the format:
|
384 warnings on Filtered down the warnings using the (updated) steps in this issue's description. warnings only (click me)
|
@shiyu1994 can you fix above warnings when have time? |
Sure. I can fix these step by step. |
I am happy to continue helping with this as well. |
Summary
Warnings caught by
cppcheck
should be resolved, if they are determined to be genuine issues and not false positives.Motivation
cppcheck
is a static analyzer for C++ code.This tool can catch some classes of issues that are not caught by other linters or tests with sanitizers, and it does that using a lightweight approach that doesn't require compiling an instrumented version of the library.
See https://sourceforge.net/p/cppcheck/wiki/ListOfChecks/ for a full list of checks.
Description
Similar to the approach taken in LightGBM with
cpplint
(#1990) andmypy
(#3867), for a time these checks might be run in continuous integration without blocking merges, just as extra information about the state of the code.See http://cppcheck.sourceforge.net/ for instructions on how to install
cppcheck
on different operating systems.LightGBM is a large, complex project and its codebase contains many possible combinations of
#ifdef
conditions. Each additional#ifdef
adds another combination of things to try, which can slow down checking substantially and have a big impact on the amount of logs produced.To ensure that
cppcheck
does not take too long and that you can see all of the logs after it's done, I recommend doing the following:git submodulue init && git submodule update --recursive
-U
to limit the number of combinations searched (you can always selectively remove these-U
checks to do more thorough checks!)To generate a list of just lines with warnings, run the following:
Piping that to
wc -l
will give you the number of warnings left.How to Contribute
Look at the current list of warnings by running
cppcheck
yourself locally (following the steps in the "Description" section above).Small pull requests focused on a single part of the codebase or type of
cppcheck
warning are greatly appreciated. Please do not submit a pull request that attempts to fix many of thecppcheck
warnings all at once.When submitting a pull request, include at least the following in the description:
References
The text was updated successfully, but these errors were encountered: