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 diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 80b43228a58..8a47b384f4b 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1046,11 +1046,22 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str } if (mSettings.checkConfiguration) { - for (const std::string &config : configurations) + 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); + } (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); @@ -1189,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; @@ -1683,6 +1695,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) @@ -1693,6 +1725,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;