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

Lots of erroneous cppcheck errors in output #120

Open
eljonny opened this issue May 1, 2024 · 3 comments
Open

Lots of erroneous cppcheck errors in output #120

eljonny opened this issue May 1, 2024 · 3 comments

Comments

@eljonny
Copy link
Contributor

eljonny commented May 1, 2024

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:
image

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!

@JacobDomagala
Copy link
Owner

        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.

@eljonny
Copy link
Contributor Author

eljonny commented May 4, 2024

Cool! This is good to know regardless of if this results in any changes!
Thank you Jacob!

@eljonny
Copy link
Contributor Author

eljonny commented May 5, 2024

        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.

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants