From c5e4c41b808a5bb42d45369be9e3c3a16ca1bb60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Wed, 11 Dec 2024 11:52:01 +0100 Subject: [PATCH] show classification and guideline in stderr --- lib/errorlogger.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index aa3728182b22..b4621f49d099 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -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) { @@ -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);