Skip to content

Commit

Permalink
Merge pull request #4471 from bruntib/fix_checkers_label_command
Browse files Browse the repository at this point in the history
[fix] CodeChecker checkers --label option:value doesn't list checkers
  • Loading branch information
cservakt authored Mar 3, 2025
2 parents 8323e90 + 300acda commit b8f90ed
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
5 changes: 3 additions & 2 deletions analyzer/codechecker_analyzer/cmd/checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,14 @@ def __get_detailed_checker_info(
if args.profile not in available_profiles:
LOG.error("Checker profile '%s' does not exist!",
args.profile)
LOG.error("To list available profiles, use '--profile list'.")
LOG.error("To list available profiles, use '--profile' "
"without argument.")
sys.exit(1)

profile_checkers.append((f'profile:{args.profile}', True))

if 'label' in args:
profile_checkers.extend((label, True) for label in args.label)
profile_checkers.append((args.label, True))

if 'severity' in args:
profile_checkers.append((f'severity:{args.severity}', True))
Expand Down
25 changes: 25 additions & 0 deletions analyzer/tests/functional/cmdline/test_cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,31 @@ def test_checkers_profile(self):
self.assertEqual(0, out[0])
self.assertEqual(True, "default" in out[1])

def test_checkers_label(self):
""" Listing checkers with given label. """

checkers_cmd = [env.codechecker_cmd(), 'checkers', '--label']
exit_code, out, _ = run_cmd(checkers_cmd)
self.assertEqual(0, exit_code)
self.assertIn('profile', out)
self.assertIn('severity', out)
self.assertIn('guideline', out)

checkers_cmd = [
env.codechecker_cmd(), 'checkers', '--label', 'severity']
exit_code, out, _ = run_cmd(checkers_cmd)
self.assertEqual(0, exit_code)
self.assertIn('HIGH', out)
self.assertIn('MEDIUM', out)
self.assertIn('LOW', out)

checkers_cmd = [
env.codechecker_cmd(), 'checkers', '--label', 'severity:HIGH']
exit_code, out, _ = run_cmd(checkers_cmd)
self.assertEqual(0, exit_code)
self.assertIn('core.DivideZero', out)
self.assertIn('core.CallAndMessage', out)

def test_analyzers(self):
""" Listing available analyzers. """

Expand Down

0 comments on commit b8f90ed

Please sign in to comment.