Home > front end >  cppcheck: error: unrecognized command line option: "--file-filter
cppcheck: error: unrecognized command line option: "--file-filter

Time:02-12

I am developing C code on Ubuntu 20.04.

By running cppcheck -q --project=build/proj1/compile_commands.json --file-filter='src/base/Myfile.c'

I got the error

cppcheck: error: unrecognized command line option: "--file-filter=src/base/Myfile.c".

CodePudding user response:

It looks like the version of cppcheck included in Ubuntu 20.04 is not the latest:

$ apt show cppcheck | grep Version
Version: 1.90-4build1

cppcheck 1.90 was released in 2019. The --file-filter argument was introduced in commit fcd5cda97 in 2020:

$ git show fcd5cda97f10085c7def7fda6fc6199f624010ce
commit fcd5cda97f10085c7def7fda6fc6199f624010ce
Author: fuzzelhjb <[email protected]>
Date:   Fri Jan 10 08:57:37 2020  0100

    Check selected files from project (#2378)

diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp
index 3fbc7f6c6..292327051 100644
--- a/cli/cmdlineparser.cpp
    b/cli/cmdlineparser.cpp
@@ -376,6  376,10 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
                 mSettings->xml = true;
             }

             // use a file filter
             else if (std::strncmp(argv[i], "--file-filter=", 14) == 0)
                 mSettings->fileFilter = std::string(argv[i]   14);
 
             // Only print something when there are errors
             else if (std::strcmp(argv[i], "-q") == 0 || std::strcmp(argv[i], "--quiet") == 0)
                 mSettings->quiet = true;
@@ -1035,6  1039,9 @@ void CmdLineParser::printHelp()
               "    --exitcode-suppressions=<file>\n"
               "                         Used when certain messages should be displayed but\n"
               "                         should not cause a non-zero exitcode.\n"
               "    --file-filter=<str>  Analyze only those files matching the given filter str\n"
               "                         Example: --file-filter=*bar.cpp analyzes only files\n"
               "                                  that end with bar.cpp.\n"
               "    --file-list=<file>   Specify the files to check in a text file. Add one\n"
               "                         filename per line. When file is '-,' the file list will\n"
               "                         be read from standard input.\n"

The current release version of cppcheck appears to be 2.7.

  • Related