Skip to content

Commit

Permalink
show classification and guideline in stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
ludviggunne committed Dec 11, 2024
1 parent cbf4d64 commit c5e4c41
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/errorlogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,12 @@ std::string ErrorMessage::toString(bool verbose, const std::string &templateForm
// template is given. Reformat the output according to it
std::string result = templateFormat;

findAndReplace(result, "{id}", id);
// replace id with guideline if present
// replace severity with classification if present
const std::string idStr = guideline.empty() ? id : guideline;
const std::string severityStr = classification.empty() ? severityToString(severity) : classification;

findAndReplace(result, "{id}", idStr);

std::string::size_type pos1 = result.find("{inconclusive:");
while (pos1 != std::string::npos) {
Expand All @@ -642,7 +647,7 @@ std::string ErrorMessage::toString(bool verbose, const std::string &templateForm
findAndReplace(result, replaceFrom, replaceWith);
pos1 = result.find("{inconclusive:", pos1);
}
findAndReplace(result, "{severity}", severityToString(severity));
findAndReplace(result, "{severity}", severityStr);
findAndReplace(result, "{cwe}", std::to_string(cwe.id));
findAndReplace(result, "{message}", verbose ? mVerboseMessage : mShortMessage);
findAndReplace(result, "{remark}", remark);
Expand Down

0 comments on commit c5e4c41

Please sign in to comment.