Skip to content

Commit

Permalink
[feat] Unique reports by different annotations
Browse files Browse the repository at this point in the history
Two report should also be considered different if they differ only in
their annotations.
  • Loading branch information
bruntib committed Nov 21, 2024
1 parent 3229b9b commit 6538406
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ def get_report_path_hash(report: Report) -> str:
col = str(event.column)
report_path_hash += f"{line}|{col}|{event.message}|{event.file.path}"

if report.annotations:
for k, v in report.annotations.items():
report_path_hash += f"|{k}|{v}"

report_path_hash += report.checker_name
if report.report_hash:
report_path_hash += report.report_hash
Expand Down
17 changes: 14 additions & 3 deletions web/tests/functional/dynamic_results/test_dynamic_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_sort_by_timestamp(self):
results = self._cc_client.getRunResults(
None, 500, 0, None, ReportFilter(), None, False)

self.assertEqual(len(results), 4)
self.assertEqual(len(results), 5)

sort_timestamp = SortMode(SortType.TIMESTAMP, Order.ASC)

Expand Down Expand Up @@ -147,7 +147,7 @@ def test_filter_by_attribute(self):
results = self._cc_client.getRunResults(
None, 500, 0, None, testcase_filter, None, False)

self.assertEqual(len(results), 3)
self.assertEqual(len(results), 4)

self.assertTrue(all(map(
lambda report: report.annotations['testcase'].startswith('TC-'),
Expand All @@ -160,7 +160,7 @@ def test_count_by_attribute(self):
num = self._cc_client.getRunResultCount(
None, ReportFilter(), None)

self.assertEqual(num, 4)
self.assertEqual(num, 5)

testcase_filter = ReportFilter(annotations=[Pair(
first='testcase',
Expand All @@ -170,3 +170,14 @@ def test_count_by_attribute(self):
None, testcase_filter, None)

self.assertEqual(num, 2)

def test_unique_path_hash(self):
"""Test that the unique path hash is calculated when two reports differ
only in their annotations."""
results = self._cc_client.getRunResults(
None, 500, 0, None, ReportFilter(), None, False)

# The main.c_lang-tidy<blabla>.plist test file contains two
# bugprone-sizeof-expression reports that differ in their annotations.
# They should be considered as different reports.
self.assertEqual(len(results), 5)
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,54 @@
</dict>
</array>
</dict>
<dict>
<key>category</key>
<string>bugprone</string>
<key>check_name</key>
<string>bugprone-sizeof-expression</string>
<key>description</key>
<string>suspicious usage of 'sizeof(K)'; did you mean 'K'?</string>
<key>issue_hash_content_of_line_in_context</key>
<string>34f8bd4635566816af99c68456d2efc0</string>
<key>report-annotation</key>
<dict>
<key>timestamp</key>
<string>2001-02-02 09:01</string>
<key>testcase</key>
<string>TS-2</string>
<key>testcase</key>
<string>TC-2</string>
</dict>
<key>location</key>
<dict>
<key>col</key>
<integer>3</integer>
<key>file</key>
<integer>0</integer>
<key>line</key>
<integer>7</integer>
</dict>
<key>path</key>
<array>
<dict>
<key>depth</key>
<integer>0</integer>
<key>kind</key>
<string>event</string>
<key>location</key>
<dict>
<key>col</key>
<integer>3</integer>
<key>file</key>
<integer>0</integer>
<key>line</key>
<integer>7</integer>
</dict>
<key>message</key>
<string>suspicious usage of 'sizeof(K)'; did you mean 'K'?</string>
</dict>
</array>
</dict>
<dict>
<key>category</key>
<string>clang</string>
Expand Down

0 comments on commit 6538406

Please sign in to comment.