From 6c0505a6be432b82cecddbbcd5ee03b42d97e5ba Mon Sep 17 00:00:00 2001 From: romanodanilo <62891297+romanodanilo@users.noreply.github.com> Date: Tue, 10 Sep 2024 17:08:00 +0200 Subject: [PATCH] Add relative rule uid to report modules (#167) Signed-off-by: romanodanilo <62891297+romanodanilo@users.noreply.github.com> --- .../src/ui/c_checker_widget.cpp | 6 +++ .../src/report_format_text.cpp | 50 ++++++++++++++++--- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/report_modules/report_module_gui/src/ui/c_checker_widget.cpp b/src/report_modules/report_module_gui/src/ui/c_checker_widget.cpp index d72fc2f0..259d224c 100644 --- a/src/report_modules/report_module_gui/src/ui/c_checker_widget.cpp +++ b/src/report_modules/report_module_gui/src/ui/c_checker_widget.cpp @@ -727,6 +727,12 @@ void cCheckerWidget::ShowDetails(cIssue *const itemToShow) const } ssDetails << itemToShow->GetIssueLevelStr().c_str() << " | " << itemToShow->GetDescription().c_str(); + if (itemToShow->GetRuleUID() != "") + { + ssDetails << "\nruleUID: "; + ssDetails << itemToShow->GetRuleUID().c_str(); + } + // Add extended informations to description if present std::stringstream extended_info_stream; if (itemToShow->HasLocations()) diff --git a/src/report_modules/report_module_text/src/report_format_text.cpp b/src/report_modules/report_module_text/src/report_format_text.cpp index c81d5a3f..e16b646c 100644 --- a/src/report_modules/report_module_text/src/report_format_text.cpp +++ b/src/report_modules/report_module_text/src/report_format_text.cpp @@ -260,7 +260,9 @@ void WriteResults(const char *file, cResultContainer *ptrResultContainer) std::list issues; std::list rules; std::list metadata; - std::set violated_rules; + std::set info_violated_rules; + std::set warning_violated_rules; + std::set error_violated_rules; std::set addressed_rules; if (outFile.is_open()) @@ -344,10 +346,28 @@ void WriteResults(const char *file, cResultContainer *ptrResultContainer) ss << "\n " << mapIssueLevelToString[(*it_Issue)->GetIssueLevel()] << (*it_Issue)->GetDescription(); + if ((*it_Issue)->GetRuleUID() != "") + { + ss << "\n " + << "ruleUID: " << (*it_Issue)->GetRuleUID(); + } + PrintExtendedInformationIntoStream((*it_Issue), &ss); if ((*it_Issue)->GetRuleUID() != "") { - violated_rules.insert((*it_Issue)->GetRuleUID()); + eIssueLevel current_issue_level = (*it_Issue)->GetIssueLevel(); + if (current_issue_level == eIssueLevel::INFO_LVL) + { + info_violated_rules.insert((*it_Issue)->GetRuleUID()); + } + if (current_issue_level == eIssueLevel::WARNING_LVL) + { + warning_violated_rules.insert((*it_Issue)->GetRuleUID()); + } + if (current_issue_level == eIssueLevel::ERROR_LVL) + { + error_violated_rules.insert((*it_Issue)->GetRuleUID()); + } } if ((*it_Issue)->HasDomainSpecificInfo()) { @@ -408,10 +428,24 @@ void WriteResults(const char *file, cResultContainer *ptrResultContainer) ss << "\n\t-> Addressed RuleUID: " << str << "\n"; } - ss << "\nTotal number of violated rules: " << violated_rules.size(); - for (const auto &str : violated_rules) + int total_number_of_violated_rules = + info_violated_rules.size() + warning_violated_rules.size() + error_violated_rules.size(); + ss << "\nTotal number of violated rules: " << total_number_of_violated_rules << "\n"; + + ss << "\nInfo violated rules: " << info_violated_rules.size(); + for (const auto &str : info_violated_rules) { - ss << "\n\t-> Violated RuleUID: " << str << "\n"; + ss << "\n\t-> Info violation RuleUID: " << str; + } + ss << "\nWarning violated rules: " << warning_violated_rules.size(); + for (const auto &str : warning_violated_rules) + { + ss << "\n\t-> Warning violation RuleUID: " << str; + } + ss << "\nError violated rules: " << error_violated_rules.size(); + for (const auto &str : error_violated_rules) + { + ss << "\n\t-> Error violation RuleUID: " << str; } ss << "\n" << BASIC_SEPARATOR_LINE << "\n"; @@ -465,8 +499,10 @@ void PrintExtendedInformationIntoStream(cIssue *issue, std::stringstream *ssStre { for (const auto location : issue->GetLocationsContainer()) { - *ssStream << "\n " << location->GetDescription(); - + if (location->GetDescription() != "") + { + *ssStream << "\n " << location->GetDescription(); + } std::list extendedInfos = location->GetExtendedInformations(); for (std::list::iterator extIt = extendedInfos.begin(); extIt != extendedInfos.end();