Skip to content

Commit

Permalink
[server] Fix getting checker labels for 'unknown' analyzer
Browse files Browse the repository at this point in the history
Analyzer default value in the database is `unknown` string  which is not
a valid analyzer name. In this commit we will handle this use case.
  • Loading branch information
csordasmarton committed Nov 12, 2021
1 parent 85dd52d commit 29beb6e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
24 changes: 18 additions & 6 deletions web/server/codechecker_server/api/report_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1999,12 +1999,24 @@ def getCheckerDoc(self, checkerId):

@exc_to_thrift_reqfail
@timeit
def getCheckerLabels(self, checkers):
return [
list(map(lambda x: f'{x[0]}:{x[1]}',
self._context.checker_labels.labels_of_checker(
checker.checkerId, checker.analyzerName)))
for checker in checkers]
def getCheckerLabels(
self,
checkers: List[ttypes.Checker]
) -> List[List[str]]:
""" Return the list of labels to each checker. """
labels = []
for checker in checkers:
# Analyzer default value in the database is 'unknown' which is not
# a valid analyzer name. So this code handles this use case.
analyzer_name = None
if checker.analyzerName != "unknown":
analyzer_name = checker.analyzerName

labels.append(list(map(lambda x: f'{x[0]}:{x[1]}',
self._context.checker_labels.labels_of_checker(
checker.checkerId, analyzer_name))))

return labels

@exc_to_thrift_reqfail
@timeit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ def test_get_checker_labels(self):
self.assertEqual(len(checker_labels), 1)
self.assertEqual(set(checker_labels[0]), div_zero_labels)

checker_labels = self._cc_client.getCheckerLabels([
Checker('unknown', 'core.DivideZero')])
self.assertEqual(len(checker_labels), 1)
self.assertEqual(set(checker_labels[0]), div_zero_labels)

checker_labels = self._cc_client.getCheckerLabels([
Checker('clangsa', 'core.DivideZero'),
Checker('clang-tidy', 'dummy-checker')])
Expand Down

0 comments on commit 29beb6e

Please sign in to comment.