diff --git a/tools/report-converter/codechecker_report_converter/report/parser/plist.py b/tools/report-converter/codechecker_report_converter/report/parser/plist.py index 0ae3ec61b6..54104b37cd 100644 --- a/tools/report-converter/codechecker_report_converter/report/parser/plist.py +++ b/tools/report-converter/codechecker_report_converter/report/parser/plist.py @@ -475,16 +475,17 @@ def convert( if report.analyzer_name: diagnostic['type'] = report.analyzer_name - control_edges = [] + path = [] if report.bug_path_positions: for i in range(len(report.bug_path_positions) - 1): start = report.bug_path_positions[i] end = report.bug_path_positions[i + 1] if start.range and end.range: - control_edges.append(self._create_control_edge( + edge = self._create_control_edge( start.range, start.file, end.range, end.file, - file_index_map)) + file_index_map) + path.append(self._create_control_edges([edge])) elif len(report.bug_path_events) > 1: # Create bug path positions from bug path events. for i in range(len(report.bug_path_events) - 1): @@ -497,14 +498,11 @@ def convert( if start_range == end_range: continue - control_edges.append(self._create_control_edge( + edge = self._create_control_edge( start_range, start.file, end_range, end.file, - file_index_map)) - - path = [] - if control_edges: - path.append(self._create_control_edges(control_edges)) + file_index_map) + path.append(self._create_control_edges([edge])) # Add bug path events after control points. if report.bug_path_events: @@ -572,8 +570,8 @@ def _create_event( 'message': event.message} if event.range: - data['range'] = self._create_range( - event.range, file_index_map[event.file.original_path]) + data['ranges'] = [self._create_range( + event.range, file_index_map[event.file.original_path])] return data @@ -609,8 +607,8 @@ def _create_note( 'message': note.message} if note.range: - data['range'] = self._create_range( - note.range, file_index_map[note.file.original_path]) + data['ranges'] = [self._create_range( + note.range, file_index_map[note.file.original_path])] return data diff --git a/tools/report-converter/tests/unit/analyzers/cppcheck_output_test_files/divide_zero.expected.plist b/tools/report-converter/tests/unit/analyzers/cppcheck_output_test_files/divide_zero.expected.plist index f3e453c520..073a30224c 100644 --- a/tools/report-converter/tests/unit/analyzers/cppcheck_output_test_files/divide_zero.expected.plist +++ b/tools/report-converter/tests/unit/analyzers/cppcheck_output_test_files/divide_zero.expected.plist @@ -40,24 +40,26 @@ message Division by zero - range + ranges - - col - 13 - file - 0 - line - 17 - - - col - 13 - file - 0 - line - 17 - + + + col + 13 + file + 0 + line + 17 + + + col + 13 + file + 0 + line + 17 + + diff --git a/tools/report-converter/tests/unit/analyzers/infer_output_test_files/NullDereference.java.plist b/tools/report-converter/tests/unit/analyzers/infer_output_test_files/NullDereference.java.plist index 32ba723b0e..bbeec1748f 100644 --- a/tools/report-converter/tests/unit/analyzers/infer_output_test_files/NullDereference.java.plist +++ b/tools/report-converter/tests/unit/analyzers/infer_output_test_files/NullDereference.java.plist @@ -67,6 +67,13 @@ + + kind + control + + + edges + end @@ -107,6 +114,13 @@ + + kind + control + + + edges + end @@ -147,6 +161,13 @@ + + kind + control + + + edges + end diff --git a/tools/report-converter/tests/unit/analyzers/spotbugs_output_test_files/assign.plist b/tools/report-converter/tests/unit/analyzers/spotbugs_output_test_files/assign.plist index 77f03d6a64..179eac7e1a 100644 --- a/tools/report-converter/tests/unit/analyzers/spotbugs_output_test_files/assign.plist +++ b/tools/report-converter/tests/unit/analyzers/spotbugs_output_test_files/assign.plist @@ -491,6 +491,13 @@ + + kind + control + + + edges + end diff --git a/tools/report-converter/tests/unit/analyzers/tidy_output_test_files/tidy2.plist b/tools/report-converter/tests/unit/analyzers/tidy_output_test_files/tidy2.plist index ccf2477dfe..fca126a4b2 100644 --- a/tools/report-converter/tests/unit/analyzers/tidy_output_test_files/tidy2.plist +++ b/tools/report-converter/tests/unit/analyzers/tidy_output_test_files/tidy2.plist @@ -108,6 +108,13 @@ + + kind + control + + + edges + end diff --git a/tools/report-converter/tests/unit/analyzers/tidy_output_test_files/tidy3_hh.plist b/tools/report-converter/tests/unit/analyzers/tidy_output_test_files/tidy3_hh.plist index 4f95bdadd1..3de62d1c55 100644 --- a/tools/report-converter/tests/unit/analyzers/tidy_output_test_files/tidy3_hh.plist +++ b/tools/report-converter/tests/unit/analyzers/tidy_output_test_files/tidy3_hh.plist @@ -67,6 +67,13 @@ + + kind + control + + + edges + end @@ -107,6 +114,13 @@ + + kind + control + + + edges + end @@ -147,6 +161,13 @@ + + kind + control + + + edges + end @@ -187,6 +208,13 @@ + + kind + control + + + edges + end diff --git a/tools/report-converter/tests/unit/analyzers/tsan_output_test_files/tsan.plist b/tools/report-converter/tests/unit/analyzers/tsan_output_test_files/tsan.plist index 1a42fcc44b..c7f53d00dc 100644 --- a/tools/report-converter/tests/unit/analyzers/tsan_output_test_files/tsan.plist +++ b/tools/report-converter/tests/unit/analyzers/tsan_output_test_files/tsan.plist @@ -89,6 +89,13 @@ + + kind + control + + + edges + end diff --git a/web/tests/functional/report_viewer_api/test_get_run_results.py b/web/tests/functional/report_viewer_api/test_get_run_results.py index 6e21379d20..b9bb0f7c59 100644 --- a/web/tests/functional/report_viewer_api/test_get_run_results.py +++ b/web/tests/functional/report_viewer_api/test_get_run_results.py @@ -352,6 +352,22 @@ def test_unqiue_report_details(self): self.assertTrue(any(res.details for res in run_results)) + def test_report_path_and_events(self): + """ + Test that bug path events and control points are stored properly. + """ + sort_mode = SortMode(SortType.FILENAME, Order.ASC) + + report_filter = ReportFilter( + checkerName=['core.DivideZero'], + filepath=['*path_begin.cpp']) + + report = self._cc_client.getRunResults( + [self._runid], 1, 0, [sort_mode], report_filter, None, True)[0] + + self.assertEqual(len(report.details.executionPath), 7) + self.assertEqual(len(report.details.pathEvents), 5) + def test_get_checker_labels(self): checker_labels = self._cc_client.getCheckerLabels([]) self.assertEqual(len(checker_labels), 0)