Skip to content

Commit

Permalink
fixed #13134 - no longer implicitly enable missingInclude with `inf…
Browse files Browse the repository at this point in the history
…ormation` (danmar#6826)

this was deprecated in 2.11
  • Loading branch information
firewave committed Sep 25, 2024
1 parent 3309f02 commit 07883d5
Show file tree
Hide file tree
Showing 33 changed files with 27 additions and 56 deletions.
14 changes: 0 additions & 14 deletions cli/cmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
ImportProject project;

bool executorAuto = true;
int8_t logMissingInclude{0};

for (int i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
Expand Down Expand Up @@ -593,9 +592,6 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
mLogger.printError(errmsg);
return Result::Fail;
}
if (std::string(argv[i] + 10).find("missingInclude") != std::string::npos) {
--logMissingInclude;
}
}

// dump cppcheck data
Expand All @@ -615,13 +611,6 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
mSettings.addEnabled("performance");
mSettings.addEnabled("portability");
}
if (enable_arg.find("information") != std::string::npos && logMissingInclude == 0) {
++logMissingInclude;
mSettings.addEnabled("missingInclude");
}
if (enable_arg.find("missingInclude") != std::string::npos) {
--logMissingInclude;
}
}

// --error-exitcode=1
Expand Down Expand Up @@ -1406,9 +1395,6 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
}
}

if (logMissingInclude == 1)
mLogger.printMessage("'--enable=information' will no longer implicitly enable 'missingInclude' starting with 2.16. Please enable it explicitly if you require it.");

if (!loadCppcheckCfg())
return Result::Fail;

Expand Down
1 change: 1 addition & 0 deletions releasenotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ Deprecations:
-

Other:
- "missingInclude" is no longer implicitly enabled with "information" - you need to enable it explicitly now.
-
2 changes: 0 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ if (BUILD_TESTS)
endif()
if ("cfg-${TEST_NAME}" IN_LIST SKIP_TESTS)
else()
# TODO: remove missingInclude disabling when it no longer is implied by --enable=information
# TODO: add syntax check
add_test(NAME cfg-${TEST_NAME}
COMMAND $<TARGET_FILE:cppcheck>
Expand All @@ -126,7 +125,6 @@ if (BUILD_TESTS)
--inconclusive
--force
--error-exitcode=1
--disable=missingInclude
--inline-suppr
--debug-warnings
--suppress=checkersReport
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/boost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for boost.cfg
//
// Usage:
// $ cppcheck --check-library --library=boost --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/boost.cpp
// $ cppcheck --check-library --library=boost --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/boost.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/bsd.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Test library configuration for bsd.cfg
//
// Usage:
// $ cppcheck --check-library --library=bsd --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/bsd.c
// $ cppcheck --check-library --library=bsd --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/bsd.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/cairo.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for cairo.cfg
//
// Usage:
// $ cppcheck --check-library --library=cairo --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/cairo.c
// $ cppcheck --check-library --library=cairo --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/cairo.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/cppunit.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Test library configuration for cppunit.cfg
//
// Usage:
// $ cppcheck --check-library --library=cppunit --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/cppunit.cpp
// $ cppcheck --check-library --library=cppunit --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/cppunit.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/emscripten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for emscripten.cfg
//
// Usage:
// $ cppcheck --check-library --library=emscripten --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/emscripten.cpp
// $ cppcheck --check-library --library=emscripten --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/emscripten.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/gnu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for gnu.cfg
//
// Usage:
// $ cppcheck --check-library --library=gnu --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/gnu.c
// $ cppcheck --check-library --library=gnu --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/gnu.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/googletest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for googletest.cfg
//
// Usage:
// $ cppcheck --check-library --library=googletest --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/googletest.cpp
// $ cppcheck --check-library --library=googletest --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/googletest.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for gtk.cfg
//
// Usage:
// $ cppcheck --check-library --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr --library=gtk test/cfg/gtk.c
// $ cppcheck --check-library --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr --library=gtk test/cfg/gtk.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/kde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for kde.cfg
//
// Usage:
// $ cppcheck --check-library --library=kde --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/kde.cpp
// $ cppcheck --check-library --library=kde --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/kde.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/libcurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for libcurl.cfg
//
// Usage:
// $ cppcheck --check-library --library=libcurl --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/libcurl.c
// $ cppcheck --check-library --library=libcurl --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/libcurl.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/libsigc++.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for libsigc++.cfg
//
// Usage:
// $ cppcheck --check-library --library=libsigc++ --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/libsigc++.cpp
// $ cppcheck --check-library --library=libsigc++ --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/libsigc++.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for lua.cfg
//
// Usage:
// $ cppcheck --check-library --library=lua --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/lua.c
// $ cppcheck --check-library --library=lua --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/lua.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/opencv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for opencv2.cfg
//
// Usage:
// $ cppcheck --check-library --library=opencv2 --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/opencv2.cpp
// $ cppcheck --check-library --library=opencv2 --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/opencv2.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/openmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for openmp.cfg
//
// Usage:
// $ cppcheck --check-library --library=openmp --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/openmp.c
// $ cppcheck --check-library --library=openmp --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/openmp.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for openssl.cfg
//
// Usage:
// $ cppcheck --check-library --library=openssl --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/openssl.c
// $ cppcheck --check-library --library=openssl --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/openssl.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for posix.cfg
//
// Usage:
// $ cppcheck --check-library --library=posix --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/posix.c
// $ cppcheck --check-library --library=posix --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/posix.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/python.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for python.cfg
//
// Usage:
// $ cppcheck --check-library --library=python --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/python.c
// $ cppcheck --check-library --library=python --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/python.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for qt.cfg
//
// Usage:
// $ cppcheck --check-library --library=qt --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/qt.cpp
// $ cppcheck --check-library --library=qt --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/qt.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
1 change: 0 additions & 1 deletion test/cfg/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ CPPCHECK_OPT=(
"--force"
"--check-level=exhaustive"
"--error-exitcode=-1"
"--disable=missingInclude"
"--inline-suppr"
"--template=\"{file}:{line}:{severity}:{id}:{message}\""
"--debug-warnings"
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/selinux.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for selinux.cfg
//
// Usage:
// $ cppcheck --check-library --library=selinux --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/selinux.c
// $ cppcheck --check-library --library=selinux --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/selinux.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for sqlite3.cfg
//
// Usage:
// $ cppcheck --check-library --library=sqlite3 --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/sqlite3.c
// $ cppcheck --check-library --library=sqlite3 --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/sqlite3.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/std.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for std.cfg
//
// Usage:
// $ cppcheck --check-library --library=std --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/std.c
// $ cppcheck --check-library --library=std --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/std.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for std.cfg
//
// Usage:
// $ cppcheck --check-library --library=std --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/std.cpp
// $ cppcheck --check-library --library=std --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/std.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for windows.cfg
//
// Usage:
// $ cppcheck --check-library --library=windows --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/windows.cpp
// $ cppcheck --check-library --library=windows --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/windows.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/wxwidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Test library configuration for wxwidgets.cfg
//
// Usage:
// $ ./cppcheck --check-library --library=wxwidgets --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --inline-suppr test/cfg/wxwidgets.cpp
// $ ./cppcheck --check-library --library=wxwidgets --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/wxwidgets.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
Expand Down
1 change: 0 additions & 1 deletion test/cli/clang-import_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ def __test_cmd(tmp_path, file_name, extra_args, stdout_exp_1):

args = [
'--enable=information',
'--disable=missingInclude', # TODO: remove
'--verbose',
'--clang',
file_name
Expand Down
5 changes: 0 additions & 5 deletions test/cli/inline-suppress_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def test_unmatched_suppression():
'--template=simple',
'--inline-suppr',
'--enable=information',
'--disable=missingInclude',
'--error-exitcode=1',
'{}2.c'.format(__proj_inline_suppres_path)
]
Expand All @@ -79,7 +78,6 @@ def test_unmatched_suppression_path_with_extra_stuff():
'--template=simple',
'--inline-suppr',
'--enable=information',
'--disable=missingInclude',
'--error-exitcode=1',
'{}2.c'.format(__proj_inline_suppres_path)
]
Expand Down Expand Up @@ -186,7 +184,6 @@ def test_unmatched_suppression_ifdef():
'-q',
'--template=simple',
'--enable=information',
'--disable=missingInclude',
'--inline-suppr',
'-DNO_ZERO_DIV',
'trac5704/trac5704a.c'
Expand All @@ -203,7 +200,6 @@ def test_unmatched_suppression_ifdef_0():
'-q',
'--template=simple',
'--enable=information',
'--disable=missingInclude',
'--inline-suppr',
'trac5704/trac5704b.c'
]
Expand Down Expand Up @@ -272,7 +268,6 @@ def test_suppress_unmatched_inline_suppression(): # 11172
'-q',
'--template=simple',
'--enable=information',
'--disable=missingInclude',
'--suppress=unmatchedSuppression',
'--inline-suppr',
'{}2.c'.format(__proj_inline_suppres_path)
Expand Down
6 changes: 0 additions & 6 deletions test/cli/whole-program_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def __test_addon_suppress_inline(extra_args):
'--addon=misra',
'--template=simple',
'--enable=information,style',
'--disable=missingInclude', # TODO: remove
'--inline-suppr',
'--error-exitcode=1',
'whole-program/whole1.c',
Expand Down Expand Up @@ -83,7 +82,6 @@ def __test_addon_suppress_inline_project(tmpdir, extra_args):
'--addon=misra',
'--template=simple',
'--enable=information,style',
'--disable=missingInclude', # TODO: remove
'--inline-suppr',
'--error-exitcode=1',
'--project={}'.format(compile_db)
Expand Down Expand Up @@ -126,7 +124,6 @@ def __test_suppress_inline(extra_args):
'-q',
'--template=simple',
'--enable=information,style',
'--disable=missingInclude', # TODO: remove
'--inline-suppr',
'--error-exitcode=1',
'whole-program/odr1.cpp',
Expand Down Expand Up @@ -177,7 +174,6 @@ def __test_suppress_inline_project(tmpdir, extra_args):
'-q',
'--template=simple',
'--enable=information,style',
'--disable=missingInclude', # TODO: remove
'--inline-suppr',
'--error-exitcode=1',
'--project={}'.format(compile_db)
Expand Down Expand Up @@ -220,7 +216,6 @@ def __test_checkclass(extra_args):
'-q',
'--template=simple',
'--enable=information,style',
'--disable=missingInclude', # TODO: remove
'--error-exitcode=1',
'whole-program/odr1.cpp',
'whole-program/odr2.cpp'
Expand Down Expand Up @@ -265,7 +260,6 @@ def __test_checkclass_project(tmpdir, extra_args):
'-q',
'--template=simple',
'--enable=information,style',
'--disable=missingInclude', # TODO: remove
'--error-exitcode=1',
'--project={}'.format(compile_db)
]
Expand Down
3 changes: 1 addition & 2 deletions test/testcmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,8 +876,7 @@ class TestCmdlineParser : public TestFixture {
ASSERT_EQUALS_ENUM(CmdLineParser::Result::Success, parser->parseFromArgs(3, argv));
ASSERT(settings->severity.isEnabled(Severity::error));
ASSERT(settings->severity.isEnabled(Severity::information));
ASSERT(settings->checks.isEnabled(Checks::missingInclude));
ASSERT_EQUALS("cppcheck: '--enable=information' will no longer implicitly enable 'missingInclude' starting with 2.16. Please enable it explicitly if you require it.\n", logger->str());
ASSERT(!settings->checks.isEnabled(Checks::missingInclude));
}

void enabledUnusedFunction() {
Expand Down
Loading

0 comments on commit 07883d5

Please sign in to comment.