StaticAnalysis
StaticAnalysis copied to clipboard
Lots of erroneous cppcheck errors in output
I am seeing a ton of these messages in the output:
cppcheck: error: could not find any files matching the filter.
As in a run on my repo in the following screenshot:
You can check out the corresponding workflow run here.
Here's my workflow YAML: TestCPP Static analysis - cppcheck/clang-tidy
Please see the following comment on the CPPCheck sourceforge: https://sourceforge.net/p/cppcheck/discussion/general/thread/e293714bf0/#9bb4
Is there something I'm doing wrong? Is this expected behavior? And is there a way to remove these from the output?
Thanks so much!
for file in $files_to_check; do
exclude_arg=""
if [ -n "$INPUT_EXCLUDE_DIR" ]; then
exclude_arg="-i$GITHUB_WORKSPACE/$INPUT_EXCLUDE_DIR"
fi
# Replace '/' with '_'
file_name=$(echo "$file" | tr '/' '_')
debug_print "Running cppcheck --project=compile_commands.json $CPPCHECK_ARGS --file-filter=$file --output-file=cppcheck_$file_name.txt $exclude_arg"
eval cppcheck --project=compile_commands.json "$CPPCHECK_ARGS" --file-filter="$file" --output-file="cppcheck_$file_name.txt" "$exclude_arg" || true
done
This is the snippet for running cppcheck. files_to_check contains both header and source files, so when cppcheck is being executed with file as header file, it will generate the error you encountered (since compile_commands.json only contains information about source files).
This probably can be "fixed" by filtering files_to_check for source files only.
Cool! This is good to know regardless of if this results in any changes! Thank you Jacob!
for file in $files_to_check; do exclude_arg="" if [ -n "$INPUT_EXCLUDE_DIR" ]; then exclude_arg="-i$GITHUB_WORKSPACE/$INPUT_EXCLUDE_DIR" fi # Replace '/' with '_' file_name=$(echo "$file" | tr '/' '_') debug_print "Running cppcheck --project=compile_commands.json $CPPCHECK_ARGS --file-filter=$file --output-file=cppcheck_$file_name.txt $exclude_arg" eval cppcheck --project=compile_commands.json "$CPPCHECK_ARGS" --file-filter="$file" --output-file="cppcheck_$file_name.txt" "$exclude_arg" || true doneThis is the snippet for running cppcheck.
files_to_checkcontains both header and source files, so whencppcheckis being executed withfileas header file, it will generate the error you encountered (sincecompile_commands.jsononly contains information about source files).This probably can be "fixed" by filtering
files_to_checkfor source files only.
Thinking about this a little more it makes a ton of sense, I have a few boost projects in my repo that have tons of header files. I'll see if there's a way with cppcheck to just ignore .hpp files that I can add to the cppcheck_args variable. Thanks again for this! I got the PR comment functionality working and it is awesome. Great work man!