From bc5023775d800ebb88efaa11464561bf2ebc1029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 13 Dec 2023 06:53:03 +0100 Subject: [PATCH] Partial fix for #12254 (cppcheck.cfg can't be loaded from relative paths anymore) (#5760) --- cli/cmdlineparser.cpp | 8 ++++---- cli/cmdlineparser.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index df9bd320428..7f5156059a9 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -1629,10 +1629,10 @@ void CmdLineParser::printHelp() const mLogger.printRaw(oss.str()); } -bool CmdLineParser::isCppcheckPremium() { - Settings settings; - settings.loadCppcheckCfg(); // TODO: how to handle errors? - return startsWith(settings.cppcheckCfgProductName, "Cppcheck Premium"); +bool CmdLineParser::isCppcheckPremium() const { + if (mSettings.cppcheckCfgProductName.empty()) + mSettings.loadCppcheckCfg(); + return startsWith(mSettings.cppcheckCfgProductName, "Cppcheck Premium"); } bool CmdLineParser::tryLoadLibrary(Library& destination, const std::string& basepath, const char* filename) diff --git a/cli/cmdlineparser.h b/cli/cmdlineparser.h index 739d2b21b09..0df49349e26 100644 --- a/cli/cmdlineparser.h +++ b/cli/cmdlineparser.h @@ -111,7 +111,7 @@ class CmdLineParser { void printHelp() const; private: - static bool isCppcheckPremium(); + bool isCppcheckPremium() const; template bool parseNumberArg(const char* const arg, std::size_t offset, T& num, bool mustBePositive = false)