Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[server] Fix getting checker labels for 'unknown' analyzer #3491

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 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,25 @@ 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