From fd158112151da0e17011d4a4836dbd959d92c058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Thu, 26 Jan 2023 22:28:04 +0100 Subject: [PATCH] de-coupled `--check-library` from `information` severity and other dependencies (#3861) --- cli/cmdlineparser.cpp | 2 -- lib/checkfunctions.cpp | 2 +- lib/checkleakautovar.cpp | 2 +- lib/checkunusedvar.cpp | 16 ++++++++++++++-- lib/tokenize.cpp | 2 +- man/manual-ja.docbook | 4 ++-- man/manual.md | 2 +- man/reference-cfg-format.md | 6 +++--- test/cfg/boost.cpp | 2 +- test/cfg/bsd.c | 2 +- test/cfg/cairo.c | 2 +- test/cfg/cppunit.cpp | 2 +- test/cfg/gnu.c | 2 +- test/cfg/googletest.cpp | 2 +- test/cfg/gtk.c | 2 +- test/cfg/kde.cpp | 2 +- test/cfg/libcurl.c | 2 +- test/cfg/libsigc++.cpp | 2 +- test/cfg/lua.c | 2 +- test/cfg/opencv2.cpp | 2 +- test/cfg/openmp.c | 2 +- test/cfg/openssl.c | 2 +- test/cfg/posix.c | 2 +- test/cfg/python.c | 2 +- test/cfg/qt.cpp | 2 +- test/cfg/runtests.sh | 2 +- test/cfg/sqlite3.c | 2 +- test/cfg/std.c | 2 +- test/cfg/std.cpp | 2 +- test/cfg/windows.cpp | 2 +- test/cfg/wxwidgets.cpp | 2 +- test/testfunctions.cpp | 6 ++---- test/testleakautovar.cpp | 4 ---- test/testuninitvar.cpp | 1 - test/testunusedvar.cpp | 1 - 35 files changed, 48 insertions(+), 46 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 1fb18b928..9db58c500 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -246,8 +246,6 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[]) // Check library definitions else if (std::strcmp(argv[i], "--check-library") == 0) { mSettings->checkLibrary = true; - // need to add "information" or no messages will be shown at all - mSettings->addEnabled("information"); } else if (std::strncmp(argv[i], "--checks-max-time=", 18) == 0) { diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index 761c8449e..50bb91c65 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -594,7 +594,7 @@ void CheckFunctions::memsetValueOutOfRangeError(const Token *tok, const std::str void CheckFunctions::checkLibraryMatchFunctions() { - if (!mSettings->checkLibrary || !mSettings->severity.isEnabled(Severity::information)) + if (!mSettings->checkLibrary) return; bool insideNew = false; diff --git a/lib/checkleakautovar.cpp b/lib/checkleakautovar.cpp index ab8672918..0e0dc25cf 100644 --- a/lib/checkleakautovar.cpp +++ b/lib/checkleakautovar.cpp @@ -169,7 +169,7 @@ void CheckLeakAutoVar::deallocReturnError(const Token *tok, const Token *dealloc void CheckLeakAutoVar::configurationInfo(const Token* tok, const std::string &functionName) { - if (mSettings->checkLibrary && mSettings->severity.isEnabled(Severity::information)) { + if (mSettings->checkLibrary) { reportError(tok, Severity::information, "checkLibraryUseIgnore", diff --git a/lib/checkunusedvar.cpp b/lib/checkunusedvar.cpp index 7aa6433fb..00bd1ed4c 100644 --- a/lib/checkunusedvar.cpp +++ b/lib/checkunusedvar.cpp @@ -1147,14 +1147,14 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const void CheckUnusedVar::checkFunctionVariableUsage() { - if (!mSettings->severity.isEnabled(Severity::style)) + if (!mSettings->severity.isEnabled(Severity::style) && !mSettings->checkLibrary) return; // Parse all executing scopes.. const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase(); auto reportLibraryCfgError = [this](const Token* tok, const std::string& typeName) { - if (mSettings->checkLibrary && mSettings->severity.isEnabled(Severity::information)) { + if (mSettings->checkLibrary) { reportError(tok, Severity::information, "checkLibraryCheckType", @@ -1380,16 +1380,25 @@ void CheckUnusedVar::checkFunctionVariableUsage() void CheckUnusedVar::unusedVariableError(const Token *tok, const std::string &varname) { + if (!mSettings->severity.isEnabled(Severity::style)) + return; + reportError(tok, Severity::style, "unusedVariable", "$symbol:" + varname + "\nUnused variable: $symbol", CWE563, Certainty::normal); } void CheckUnusedVar::allocatedButUnusedVariableError(const Token *tok, const std::string &varname) { + if (!mSettings->severity.isEnabled(Severity::style)) + return; + reportError(tok, Severity::style, "unusedAllocatedMemory", "$symbol:" + varname + "\nVariable '$symbol' is allocated memory that is never used.", CWE563, Certainty::normal); } void CheckUnusedVar::unreadVariableError(const Token *tok, const std::string &varname, bool modified) { + if (!mSettings->severity.isEnabled(Severity::style)) + return; + if (modified) reportError(tok, Severity::style, "unreadVariable", "$symbol:" + varname + "\nVariable '$symbol' is modified but its new value is never used.", CWE563, Certainty::normal); else @@ -1398,6 +1407,9 @@ void CheckUnusedVar::unreadVariableError(const Token *tok, const std::string &va void CheckUnusedVar::unassignedVariableError(const Token *tok, const std::string &varname) { + if (!mSettings->severity.isEnabled(Severity::style)) + return; + reportError(tok, Severity::style, "unassignedVariable", "$symbol:" + varname + "\nVariable '$symbol' is not assigned a value.", CWE665, Certainty::normal); } diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 19a3891f3..7812b9661 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -7172,7 +7172,7 @@ bool Tokenizer::isScopeNoReturn(const Token *endScopeToken, bool *unknown) const } if (unknown) *unknown = !unknownFunc.empty(); - if (!unknownFunc.empty() && mSettings->checkLibrary && mSettings->severity.isEnabled(Severity::information)) { + if (!unknownFunc.empty() && mSettings->checkLibrary) { bool warn = true; if (Token::simpleMatch(endScopeToken->tokAt(-2), ") ; }")) { const Token * const ftok = endScopeToken->linkAt(-2)->previous(); diff --git a/man/manual-ja.docbook b/man/manual-ja.docbook index 2fa180636..1c13d3d05 100644 --- a/man/manual-ja.docbook +++ b/man/manual-ja.docbook @@ -1360,9 +1360,9 @@ Checking minsize.c... # cppcheck noreturn.c Checking noreturn.c... - しかし、--check-library--enable=informationをつかうとエラーが出力されます。: + しかし、--check-library をつかうとエラーが出力されます。: - # cppcheck --check-library --enable=information noreturn.c + # cppcheck --check-library noreturn.c Checking noreturn.c... [noreturn.c:7]: (information) --check-library: Function ZeroMemory() should have <noreturn> configuration diff --git a/man/manual.md b/man/manual.md index 1aa1d7b9c..36c190594 100644 --- a/man/manual.md +++ b/man/manual.md @@ -925,7 +925,7 @@ Cppcheck already contains configurations for several libraries. They can be load ## Using your own custom .cfg file -You can create and use your own .cfg files for your projects. Use `--check-library` and `--enable=information` to get hints about what you should configure. +You can create and use your own .cfg files for your projects. Use `--check-library` to get hints about what you should configure. You can use the `Library Editor` in the `Cppcheck GUI` to edit configuration files. It is available in the `View` menu. diff --git a/man/reference-cfg-format.md b/man/reference-cfg-format.md index 2c1a88c49..657798c3a 100644 --- a/man/reference-cfg-format.md +++ b/man/reference-cfg-format.md @@ -89,7 +89,7 @@ If instead `dostuff` takes care of the memory then this can be configured with: -The `` configuration has no logical purpose. You will get the same warnings without it. Use it to silence --check-library information messages. +The `` configuration has no logical purpose. You will get the same warnings without it. Use it to silence `--check-library` information messages. # Function behavior @@ -397,9 +397,9 @@ In theory, if ZeroMemory terminates the program then there is no bug. Cppcheck t $ cppcheck noreturn.c Checking noreturn.c... -However if you use `--check-library` and `--enable=information` you'll get this: +However if you use `--check-library` you'll get this: - $ cppcheck --check-library --enable=information noreturn.c + $ cppcheck --check-library noreturn.c Checking noreturn.c... [noreturn.c:7]: (information) --check-library: Function ZeroMemory() should have configuration diff --git a/test/cfg/boost.cpp b/test/cfg/boost.cpp index f106c66a6..08d54b049 100644 --- a/test/cfg/boost.cpp +++ b/test/cfg/boost.cpp @@ -2,7 +2,7 @@ // Test library configuration for boost.cfg // // Usage: -// $ cppcheck --check-library --enable=information --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/boost.cpp +// $ cppcheck --check-library --library=boost --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/boost.cpp // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/bsd.c b/test/cfg/bsd.c index ba7abb31c..c24231745 100644 --- a/test/cfg/bsd.c +++ b/test/cfg/bsd.c @@ -1,7 +1,7 @@ // Test library configuration for bsd.cfg // // Usage: -// $ cppcheck --library=bsd --check-library --enable=information --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/bsd.c +// $ cppcheck --check-library --library=bsd --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/bsd.c // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/cairo.c b/test/cfg/cairo.c index 27702c0dc..9a2c93264 100644 --- a/test/cfg/cairo.c +++ b/test/cfg/cairo.c @@ -2,7 +2,7 @@ // Test library configuration for cairo.cfg // // Usage: -// $ cppcheck --check-library --library=cairo --enable=information --error-exitcode=1 --inline-suppr --suppress=missingIncludeSystem test/cfg/cairo.c +// $ cppcheck --check-library --library=cairo --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/cairo.c // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/cppunit.cpp b/test/cfg/cppunit.cpp index e2f680a38..9dae2d99b 100644 --- a/test/cfg/cppunit.cpp +++ b/test/cfg/cppunit.cpp @@ -1,7 +1,7 @@ // Test library configuration for cppunit.cfg // // Usage: -// $ cppcheck --check-library --enable=information --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/cppunit.cpp +// $ cppcheck --check-library --library=cppunit --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/cppunit.cpp // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/gnu.c b/test/cfg/gnu.c index 3b04a1fda..fde4c819a 100644 --- a/test/cfg/gnu.c +++ b/test/cfg/gnu.c @@ -2,7 +2,7 @@ // Test library configuration for gnu.cfg // // Usage: -// $ cppcheck --check-library --library=gnu --enable=information --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/gnu.c +// $ cppcheck --check-library --library=gnu --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/gnu.c // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/googletest.cpp b/test/cfg/googletest.cpp index 37234a703..19e078366 100644 --- a/test/cfg/googletest.cpp +++ b/test/cfg/googletest.cpp @@ -2,7 +2,7 @@ // Test library configuration for googletest.cfg // // Usage: -// $ cppcheck --check-library --library=googletest --enable=information --error-exitcode=1 --inline-suppr --suppress=missingIncludeSystem test/cfg/googletest.cpp +// $ cppcheck --check-library --library=googletest --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/googletest.cpp // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/gtk.c b/test/cfg/gtk.c index 47624972b..ac086fdae 100644 --- a/test/cfg/gtk.c +++ b/test/cfg/gtk.c @@ -2,7 +2,7 @@ // Test library configuration for gtk.cfg // // Usage: -// $ cppcheck --check-library --enable=information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr --library=gtk test/cfg/gtk.cpp +// $ cppcheck --check-library --library=gtk --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr --library=gtk test/cfg/gtk.cpp // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/kde.cpp b/test/cfg/kde.cpp index f7c01fc33..ced00c6d1 100644 --- a/test/cfg/kde.cpp +++ b/test/cfg/kde.cpp @@ -2,7 +2,7 @@ // Test library configuration for kde.cfg // // Usage: -// $ cppcheck --check-library --enable=information --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/kde.cpp +// $ cppcheck --check-library --library=kde --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/kde.cpp // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/libcurl.c b/test/cfg/libcurl.c index 7205905f8..2cb8a8832 100644 --- a/test/cfg/libcurl.c +++ b/test/cfg/libcurl.c @@ -2,7 +2,7 @@ // Test library configuration for libcurl.cfg // // Usage: -// $ cppcheck --check-library --library=libcurl --enable=information --error-exitcode=1 --inline-suppr --suppress=missingIncludeSystem test/cfg/libcurl.c +// $ cppcheck --check-library --library=libcurl --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/libcurl.c // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/libsigc++.cpp b/test/cfg/libsigc++.cpp index f8989e7d5..a52ce40da 100644 --- a/test/cfg/libsigc++.cpp +++ b/test/cfg/libsigc++.cpp @@ -2,7 +2,7 @@ // Test library configuration for libsigc++.cfg // // Usage: -// $ cppcheck --check-library --enable=information --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/libsigc++.cpp +// $ cppcheck --check-library --library=libsigc++ --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/libsigc++.cpp // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/lua.c b/test/cfg/lua.c index 6f254cc12..a3fc7815d 100644 --- a/test/cfg/lua.c +++ b/test/cfg/lua.c @@ -2,7 +2,7 @@ // Test library configuration for lua.cfg // // Usage: -// $ cppcheck --check-library --library=lua --enable=information --error-exitcode=1 --inline-suppr --suppress=missingIncludeSystem test/cfg/lua.c +// $ cppcheck --check-library --library=lua --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/lua.c // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/opencv2.cpp b/test/cfg/opencv2.cpp index e88ee4ab1..a5361c1cf 100644 --- a/test/cfg/opencv2.cpp +++ b/test/cfg/opencv2.cpp @@ -2,7 +2,7 @@ // Test library configuration for opencv2.cfg // // Usage: -// $ cppcheck --check-library --library=cairo --enable=information --error-exitcode=1 --inline-suppr --suppress=missingIncludeSystem test/cfg/opencv2.cpp +// $ cppcheck --check-library --library=opencv2 --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/opencv2.cpp // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/openmp.c b/test/cfg/openmp.c index b883d82ee..a50e28250 100644 --- a/test/cfg/openmp.c +++ b/test/cfg/openmp.c @@ -2,7 +2,7 @@ // Test library configuration for openmp.cfg // // Usage: -// $ cppcheck --check-library --library=openmp --enable=information --error-exitcode=1 --inline-suppr --suppress=missingIncludeSystem test/cfg/openmp.c +// $ cppcheck --check-library --library=openmp --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/openmp.c // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/openssl.c b/test/cfg/openssl.c index abbd77030..4596c9fe0 100644 --- a/test/cfg/openssl.c +++ b/test/cfg/openssl.c @@ -2,7 +2,7 @@ // Test library configuration for openssl.cfg // // Usage: -// $ cppcheck --check-library --library=openssl --enable=information --error-exitcode=1 --inline-suppr --suppress=missingIncludeSystem test/cfg/openssl.c +// $ cppcheck --check-library --library=openssl --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/openssl.c // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/posix.c b/test/cfg/posix.c index 4e5df474b..708b60a09 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -2,7 +2,7 @@ // Test library configuration for posix.cfg // // Usage: -// $ cppcheck --check-library --library=posix --enable=information --error-exitcode=1 --inline-suppr --suppress=missingIncludeSystem test/cfg/posix.c +// $ cppcheck --check-library --library=posix --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/posix.c // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/python.c b/test/cfg/python.c index 34aac8c41..e887e44ed 100644 --- a/test/cfg/python.c +++ b/test/cfg/python.c @@ -2,7 +2,7 @@ // Test library configuration for python.cfg // // Usage: -// $ cppcheck --check-library --library=python --enable=information --error-exitcode=1 --inline-suppr --suppress=missingIncludeSystem test/cfg/python.c +// $ cppcheck --check-library --library=python --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/python.c // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/qt.cpp b/test/cfg/qt.cpp index 716fab94c..92cda332f 100644 --- a/test/cfg/qt.cpp +++ b/test/cfg/qt.cpp @@ -2,7 +2,7 @@ // Test library configuration for qt.cfg // // Usage: -// $ cppcheck --check-library --enable=information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr --library=qt test/cfg/qt.cpp +// $ cppcheck --check-library --library=qt --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/qt.cpp // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/runtests.sh b/test/cfg/runtests.sh index 0468d75ae..6ffc4a521 100755 --- a/test/cfg/runtests.sh +++ b/test/cfg/runtests.sh @@ -23,7 +23,7 @@ CPPCHECK="$DIR"../../cppcheck CFG="$DIR"../../cfg/ # Cppcheck options -CPPCHECK_OPT='--check-library --platform=unix64 --enable=information --enable=style --error-exitcode=-1 --suppress=missingIncludeSystem --inline-suppr --template="{file}:{line}:{severity}:{id}:{message}"' +CPPCHECK_OPT='--check-library --platform=unix64 --enable=style --error-exitcode=-1 --suppress=missingIncludeSystem --inline-suppr --template="{file}:{line}:{severity}:{id}:{message}"' # Compiler settings CXX=g++ diff --git a/test/cfg/sqlite3.c b/test/cfg/sqlite3.c index 4a9a1856c..74ed8fdee 100644 --- a/test/cfg/sqlite3.c +++ b/test/cfg/sqlite3.c @@ -2,7 +2,7 @@ // Test library configuration for sqlite3.cfg // // Usage: -// $ cppcheck --check-library --library=sqlite3 --enable=information --error-exitcode=1 --inline-suppr --suppress=missingIncludeSystem test/cfg/sqlite3.c +// $ cppcheck --check-library --enable=style --library=sqlite3 --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/sqlite3.c // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/std.c b/test/cfg/std.c index cd4bfc977..c49a7dcac 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -2,7 +2,7 @@ // Test library configuration for std.cfg // // Usage: -// $ cppcheck --check-library --enable=information --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/std.c +// $ cppcheck --check-library --library=std --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/std.c // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 0b569fc98..3afe3d80c 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -2,7 +2,7 @@ // Test library configuration for std.cfg // // Usage: -// $ cppcheck --check-library --enable=information --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/std.cpp +// $ cppcheck --check-library --library=std --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/std.cpp // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/windows.cpp b/test/cfg/windows.cpp index ae52271c9..154c02f56 100644 --- a/test/cfg/windows.cpp +++ b/test/cfg/windows.cpp @@ -2,7 +2,7 @@ // Test library configuration for windows.cfg // // Usage: -// $ cppcheck --check-library --library=windows --enable=information --error-exitcode=1 --inline-suppr --suppress=missingIncludeSystem test/cfg/windows.cpp +// $ cppcheck --check-library --library=windows --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/windows.cpp // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/cfg/wxwidgets.cpp b/test/cfg/wxwidgets.cpp index 7180950ea..16fd5b740 100644 --- a/test/cfg/wxwidgets.cpp +++ b/test/cfg/wxwidgets.cpp @@ -2,7 +2,7 @@ // Test library configuration for wxwidgets.cfg // // Usage: -// $ ./cppcheck --check-library --enable=information --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr '--template="{file}:{line}:{severity}:{id}:{message}"' --inconclusive --library=wxwidgets -f test/cfg/wxwidgets.cpp +// $ ./cppcheck --check-library --library=wxwidgets --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/wxwidgets.cpp // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index f7f4e3fab..6faa1a832 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -1827,9 +1827,8 @@ private: } void checkLibraryMatchFunctions() { + const auto settings_old = settings; settings.checkLibrary = true; - auto severity_old = settings.severity; - settings.severity.enable(Severity::information); check("void f() {\n" " lib_func();" @@ -1951,8 +1950,7 @@ private: "[test.cpp:5]: (information) --check-library: There is no matching configuration for function auto::push_back()\n", errout.str()); - settings.severity = severity_old; - settings.checkLibrary = false; + settings = settings_old; } void checkUseStandardLibrary1() { diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index 05ccf2650..647cfb571 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -239,7 +239,6 @@ private: // Check for leaks.. CheckLeakAutoVar c; settings.checkLibrary = true; - settings.severity.enable(Severity::information); c.runChecks(&tokenizer, &settings, this); } @@ -255,7 +254,6 @@ private: // Check for leaks.. CheckLeakAutoVar c; settings_.checkLibrary = true; - settings_.severity.enable(Severity::information); c.runChecks(&tokenizer, &settings_, this); } @@ -2645,7 +2643,6 @@ private: // Check for leaks.. CheckLeakAutoVar c; settings.checkLibrary = true; - settings.addEnabled("information"); c.runChecks(&tokenizer, &settings, this); } @@ -2696,7 +2693,6 @@ private: // Check for leaks.. CheckLeakAutoVar checkLeak; settings.checkLibrary = true; - settings.severity.enable(Severity::information); checkLeak.runChecks(&tokenizer, &settings, this); } diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 28d4d16e5..dd29944b5 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -4601,7 +4601,6 @@ private: void uninitvar_configuration() { const auto oldSettings = settings; - settings.severity.enable(Severity::information); settings.checkLibrary = true; checkUninitVar("int f() {\n" diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 5f3cc2743..06f49d2c7 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -36,7 +36,6 @@ private: void run() override { settings.severity.enable(Severity::style); - settings.severity.enable(Severity::information); settings.checkLibrary = true; LOAD_LIB_2(settings.library, "std.cfg");