diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 9c411a8b0af..10e2f3738bf 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1684,7 +1684,7 @@ void CppCheck::tooManyConfigsError(const std::string &file, const int numberOfCo msg << "Too many #ifdef configurations - cppcheck only checks " << mSettings.maxConfigs; if (numberOfConfigurations > mSettings.maxConfigs) msg << " of " << numberOfConfigurations << " configurations. Use --force to check all configurations.\n"; - if (file.empty()) + else if (file.empty()) msg << " configurations. Use --force to check all configurations. For more details, use --enable=information.\n"; msg << "The checking of the file will be interrupted because there are too many " "#ifdef configurations. Checking of all #ifdef configurations can be forced " diff --git a/test/testcppcheck.cpp b/test/testcppcheck.cpp index 8535bbfe47c..a9ef10e79a7 100644 --- a/test/testcppcheck.cpp +++ b/test/testcppcheck.cpp @@ -89,6 +89,13 @@ class TestCppcheck : public TestFixture { ErrorLogger2 errorLogger; CppCheck::getErrorMessages(errorLogger); ASSERT(!errorLogger.ids.empty()); + ASSERT(!errorLogger.errmsgs.empty()); + + const auto it = std::next(errorLogger.errmsgs.cbegin()); + const std::string shortMsg = it->toString(false, templateFormat, ""); + const std::string debugMsg = it->toString(true, templateFormat, ""); + ASSERT_EQUALS(shortMsg, "nofile:0:0: information: Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information. [toomanyconfigs]"); + ASSERT_EQUALS(debugMsg, "nofile:0:0: information: The checking of the file will be interrupted because there are too many #ifdef configurations. Checking of all #ifdef configurations can be forced by --force command line option or from GUI preferences. However that may increase the checking time. For more details, use --enable=information. [toomanyconfigs]"); // Check if there are duplicate error ids in errorLogger.id std::string duplicate;