Search code examples
cppcheck

Can cppcheck do a dry run to list all files without actually checking them?


I am running cppcheck on a big project and I'm trying to exclude a couple of files and folders that are 3rd party and/or generated. Is it possible to let cppcheck do a dry run and let it show the files it would normally try to check?


Solution

  • No, such a functionality is not (yet) implemented.

    The best solution that comes to my mind is to use options like this:

    cppcheck --check-config ./ 2> /dev/null
    

    Explanation:

    • The --check-config option lets Cppcheck only check if includes are missing. No further analysis is done, no bugs are reported.
    • Replace ./ with the path to the source files that you want to have the output for.
    • 2> /dev/null suppresses Cppcheck messages for missing includes and other errors

    Running this on the Cppcheck sources I get an output like this:

    $ ./cppcheck --check-config ./ 2> /dev/null
    Checking addons/test/cert-test.c ...
    1/291 files checked 0% done
    Checking addons/test/cert-test.cpp ...
    2/291 files checked 0% done
    Checking addons/test/misc-test.cpp ...
    3/291 files checked 0% done
    Checking addons/test/misra/misra-suppressions1-test.c ...
    4/291 files checked 0% done
    Checking addons/test/misra/misra-suppressions2-test.c ...
    5/291 files checked 0% done
    Checking addons/test/misra/misra-test.c ...
    6/291 files checked 0% done
    Checking addons/test/misra/misra-test.cpp ...
    7/291 files checked 0% done
    Checking addons/test/naming_test.c ...
    8/291 files checked 0% done
    Checking addons/test/naming_test.cpp ...
    9/291 files checked 0% done
    Checking addons/test/namingng_test.c ...
    10/291 files checked 0% done
    Checking addons/test/path1/misra-suppressions1-test.c ...
    11/291 files checked 0% done
    Checking addons/test/path1/misra-suppressions2-test.c ...
    ...