From c42927c49f8fd4ed7d3317b6c95abbe3e6b52e41 Mon Sep 17 00:00:00 2001 From: Daniel Krupp Date: Wed, 30 Oct 2024 20:51:08 +0100 Subject: [PATCH] Add a superhashmap file per plist which contains the unique hash for each report in the plist --- .../report/__init__.py | 2 ++ .../report/report_file.py | 22 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/tools/report-converter/codechecker_report_converter/report/__init__.py b/tools/report-converter/codechecker_report_converter/report/__init__.py index db34797059..88532617c7 100644 --- a/tools/report-converter/codechecker_report_converter/report/__init__.py +++ b/tools/report-converter/codechecker_report_converter/report/__init__.py @@ -305,6 +305,7 @@ def __init__( checker_name: str, severity: Optional[str] = None, report_hash: Optional[str] = None, + report_super_hash: Optional[str] = None, analyzer_name: Optional[str] = None, category: Optional[str] = None, type: Optional[str] = None, # pylint: disable=redefined-builtin @@ -337,6 +338,7 @@ def __init__( self.message = message self.checker_name = checker_name self.severity = severity + self.report_hash = report_super_hash self.report_hash = report_hash self.analyzer_name = analyzer_name self.category = category # TODO: Remove this. DEPRECATED. diff --git a/tools/report-converter/codechecker_report_converter/report/report_file.py b/tools/report-converter/codechecker_report_converter/report/report_file.py index 41fa9c6db5..5718ec3a7e 100644 --- a/tools/report-converter/codechecker_report_converter/report/report_file.py +++ b/tools/report-converter/codechecker_report_converter/report/report_file.py @@ -14,6 +14,7 @@ from codechecker_report_converter.report import File, Report from codechecker_report_converter.report.checker_labels import CheckerLabels from codechecker_report_converter.report.hash import HashType +import codechecker_report_converter.report.hash as report_hash from codechecker_report_converter.report.parser import plist, sarif from codechecker_report_converter.report.parser.base import AnalyzerInfo @@ -82,7 +83,26 @@ def create( if parser: data = parser.convert(reports, analyzer_info) parser.write(data, output_file_path) - + create_super_hash_map(reports, output_file_path + ".map") + +def create_super_hash_map( + reports: List[Report], + map_file_name: str + ): + """ Creates plist.map file from the parse result to the given output. + The map file contains the super hashes of the reports + """ + + ### Creating a super hash map. + ### These superhashes are unique identifiers for + ### a report containing the full bug path + with open(map_file_name, "w") as shf: + superhashes = set() + for report in reports: + report.report_super_hash = report_hash.get_report_super_hash(report) + superhashes.add(report.report_super_hash) + for h in superhashes: + shf.write( h + "\n") def replace_report_hash( analyzer_result_file_path: str,