Skip to content

Commit 637a487

Browse files
committed
move guideline mapping to StdLogger
1 parent a6f72d6 commit 637a487

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

cli/cmdlineparser.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,6 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
12471247
mLogger.printError("Unknown report type \'" + typeStr + "\'");
12481248
return Result::Fail;
12491249
}
1250-
mSettings.guidelineMapping = createGuidelineMapping(mSettings.reportType);
12511250
}
12521251

12531252
// Rule given at command line

cli/cppcheckexecutor.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ namespace {
249249
public:
250250
explicit StdLogger(const Settings& settings)
251251
: mSettings(settings)
252+
, mGuidelineMapping(createGuidelineMapping(settings.reportType))
252253
{
253254
if (!mSettings.outputFile.empty()) {
254255
mErrorOutput = new std::ofstream(settings.outputFile);
@@ -342,6 +343,11 @@ namespace {
342343
* SARIF report generator
343344
*/
344345
SarifReport mSarifReport;
346+
347+
/**
348+
* Coding standard guideline mapping
349+
*/
350+
std::map<std::string, std::string> mGuidelineMapping;
345351
};
346352
}
347353

@@ -628,7 +634,7 @@ void StdLogger::reportErr(const ErrorMessage &msg)
628634

629635
ErrorMessage msgCopy = msg;
630636
msgCopy.guideline = getGuideline(msgCopy.id, mSettings.reportType,
631-
mSettings.guidelineMapping, msgCopy.severity);
637+
mGuidelineMapping, msgCopy.severity);
632638
msgCopy.classification = getClassification(msgCopy.guideline, mSettings.reportType);
633639

634640
if (mSettings.outputFormat == Settings::OutputFormat::sarif)

lib/settings.h

-3
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@ class CPPCHECKLIB WARN_UNUSED Settings {
114114
/** @brief Report type */
115115
ReportType reportType;
116116

117-
/** @brief Maps cppcheck error ids to guidelines */
118-
std::map<std::string, std::string> guidelineMapping;
119-
120117
/** @brief addons, either filename of python/json file or json data */
121118
std::unordered_set<std::string> addons;
122119

0 commit comments

Comments
 (0)