From 41862975d82058e418ccdb9ef70290f04f3552e3 Mon Sep 17 00:00:00 2001 From: firewave Date: Fri, 5 Dec 2025 10:01:50 +0100 Subject: [PATCH 1/4] CI-unixish.yml: run --check-config --- .github/workflows/CI-unixish.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index 6a7dad5fc9a..c9e12cf8656 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -693,6 +693,10 @@ jobs: make -C cmake.output autogen make -C cmake.output gui-build-deps triage-build-ui-deps + - name: Check Config + run: | + ./selfcheck.sh "--check-config" + - name: Self check run: | ./selfcheck.sh From a01585c606a0f59e01a01038f04d76f541edb9e7 Mon Sep 17 00:00:00 2001 From: firewave Date: Fri, 5 Dec 2025 10:02:24 +0100 Subject: [PATCH 2/4] print configurations with `--check-config` --- lib/cppcheck.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 80b43228a58..80e3e9a9759 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1046,8 +1046,13 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str } if (mSettings.checkConfiguration) { - for (const std::string &config : configurations) + for (const std::string &config : configurations) { + if (!mSettings.quiet && (!config.empty() && configurations.size() > 1)) { + std::string fixedpath = Path::toNativeSeparators(file.spath()); + mErrorLogger.reportOut("Checking " + fixedpath + ": " + config + "...", Color::FgGreen); + } (void)preprocessor.getcode(config, files, false); + } if (configurations.size() > maxConfigs) tooManyConfigsError(Path::toNativeSeparators(file.spath()), configurations.size()); From ffca47db861e5d757ad052b9c612a597503b6ba7 Mon Sep 17 00:00:00 2001 From: firewave Date: Fri, 5 Dec 2025 10:13:03 +0100 Subject: [PATCH 3/4] added message about skipped configurations with `--check-config` --- lib/cppcheck.cpp | 29 +++++++++++++++++++++++++++-- lib/cppcheck.h | 1 + 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 80e3e9a9759..9562c4cdf17 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1046,16 +1046,20 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str } if (mSettings.checkConfiguration) { + std::string fixedpath = Path::toNativeSeparators(file.spath()); + int checkConfig = 0; for (const std::string &config : configurations) { if (!mSettings.quiet && (!config.empty() && configurations.size() > 1)) { - std::string fixedpath = Path::toNativeSeparators(file.spath()); mErrorLogger.reportOut("Checking " + fixedpath + ": " + config + "...", Color::FgGreen); } (void)preprocessor.getcode(config, files, false); + if (++checkConfig > maxConfigs) { + skippedConfigurationMessage(fixedpath, config); + } } if (configurations.size() > maxConfigs) - tooManyConfigsError(Path::toNativeSeparators(file.spath()), configurations.size()); + tooManyConfigsError(fixedpath, configurations.size()); if (analyzerInformation) mLogger->setAnalyzerInfo(nullptr); @@ -1688,6 +1692,26 @@ void CppCheck::purgedConfigurationMessage(const std::string &file, const std::st mErrorLogger.reportErr(errmsg); } +void CppCheck::skippedConfigurationMessage(const std::string &file, const std::string& configuration) +{ + if (mSettings.severity.isEnabled(Severity::information) && file.empty()) + return; + + std::list loclist; + if (!file.empty()) { + loclist.emplace_back(file, 0, 0); + } + + ErrorMessage errmsg(std::move(loclist), + "", + Severity::information, + "The configuration '" + configuration + "' was not checked because it exceeded the threshold for maximum configuration to be checked.", + "skippedConfiguration", + Certainty::normal); + + mErrorLogger.reportErr(errmsg); +} + //--------------------------------------------------------------------------- void CppCheck::getErrorMessages(ErrorLogger &errorlogger) @@ -1698,6 +1722,7 @@ void CppCheck::getErrorMessages(ErrorLogger &errorlogger) CppCheck cppcheck(settings, supprs, errorlogger, nullptr, true, nullptr); cppcheck.purgedConfigurationMessage("",""); + cppcheck.skippedConfigurationMessage("",""); cppcheck.tooManyConfigsError("",0U); // TODO: add functions to get remaining error messages diff --git a/lib/cppcheck.h b/lib/cppcheck.h index 868100df170..bf8dd171e61 100644 --- a/lib/cppcheck.h +++ b/lib/cppcheck.h @@ -144,6 +144,7 @@ class CPPCHECKLIB CppCheck { private: void purgedConfigurationMessage(const std::string &file, const std::string& configuration); + void skippedConfigurationMessage(const std::string &file, const std::string& configuration); bool isPremiumCodingStandardId(const std::string& id) const; From fe63b979131a004dfaadee2fbd13c6d4ea8ae7d5 Mon Sep 17 00:00:00 2001 From: firewave Date: Fri, 5 Dec 2025 10:13:41 +0100 Subject: [PATCH 4/4] s [skip ci] --- lib/cppcheck.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 9562c4cdf17..8a47b384f4b 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1048,6 +1048,8 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str if (mSettings.checkConfiguration) { std::string fixedpath = Path::toNativeSeparators(file.spath()); int checkConfig = 0; + // TODO: this logic differs from the actual one during analysis + // TODO: print invalid configurations for (const std::string &config : configurations) { if (!mSettings.quiet && (!config.empty() && configurations.size() > 1)) { mErrorLogger.reportOut("Checking " + fixedpath + ": " + config + "...", Color::FgGreen); @@ -1198,6 +1200,7 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str if (!tokenizer.tokens()) continue; + // TODO: unreachable // skip rest of iteration if just checking configuration if (mSettings.checkConfiguration) continue;