Skip to content

Commit c5e4c41

Browse files
committed
show classification and guideline in stderr
1 parent cbf4d64 commit c5e4c41

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/errorlogger.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,12 @@ std::string ErrorMessage::toString(bool verbose, const std::string &templateForm
632632
// template is given. Reformat the output according to it
633633
std::string result = templateFormat;
634634

635-
findAndReplace(result, "{id}", id);
635+
// replace id with guideline if present
636+
// replace severity with classification if present
637+
const std::string idStr = guideline.empty() ? id : guideline;
638+
const std::string severityStr = classification.empty() ? severityToString(severity) : classification;
639+
640+
findAndReplace(result, "{id}", idStr);
636641

637642
std::string::size_type pos1 = result.find("{inconclusive:");
638643
while (pos1 != std::string::npos) {
@@ -642,7 +647,7 @@ std::string ErrorMessage::toString(bool verbose, const std::string &templateForm
642647
findAndReplace(result, replaceFrom, replaceWith);
643648
pos1 = result.find("{inconclusive:", pos1);
644649
}
645-
findAndReplace(result, "{severity}", severityToString(severity));
650+
findAndReplace(result, "{severity}", severityStr);
646651
findAndReplace(result, "{cwe}", std::to_string(cwe.id));
647652
findAndReplace(result, "{message}", verbose ? mVerboseMessage : mShortMessage);
648653
findAndReplace(result, "{remark}", remark);

0 commit comments

Comments
 (0)