From 19bddf861e2181ece184871beb8a055e2347c964 Mon Sep 17 00:00:00 2001 From: Nora Zinaeddin Date: Sun, 15 Dec 2024 12:35:32 +0100 Subject: [PATCH] [fix] Validate checkers ordered with prefix CC validates ordered checkers before analyzing, but didn't use to validate the checkers ordered with the "checker:" or "prefix:" option. With this fix, all ordered checkers will be validated. Fixes #4405 --- analyzer/codechecker_analyzer/analyzer.py | 49 ++++++++++++++++++----- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/analyzer/codechecker_analyzer/analyzer.py b/analyzer/codechecker_analyzer/analyzer.py index b788461e9f..2e3fe103e1 100644 --- a/analyzer/codechecker_analyzer/analyzer.py +++ b/analyzer/codechecker_analyzer/analyzer.py @@ -11,6 +11,7 @@ from collections import defaultdict +from string import Template import os import shutil import signal @@ -212,16 +213,46 @@ def perform_analysis(args, skip_handlers, filter_handlers, available_checkers.add(checker_name) if 'ordered_checkers' in args: - missing_checkers = checkers.available(args.ordered_checkers, + missing_prefixes = [] + for checker in args.ordered_checkers: + if checker[0].startswith("prefix:"): + prefix = checker[0][len("prefix:"):] + if prefix not in available_checkers and not any( + item.startswith(prefix + '.') or + item.startswith(prefix + '-') for item in + available_checkers): + missing_prefixes.append(prefix) + + ordered_checkers = [(checker[0].replace("checker:", ""), checker[1]) + if checker[0].startswith("checker:") else checker + for checker in args.ordered_checkers] + missing_checkers = checkers.available(ordered_checkers, available_checkers) - if missing_checkers: - diag_msg = "No checker(s) with these names was found:\n{}".format( - '\n'.join(missing_checkers)) - if 'no_missing_checker_error' in args: - LOG.warning(diag_msg) - else: - LOG.error(diag_msg) - LOG.info("Although it is not reccomended, if you want to " + + error_lists = { + 'prefix(es)': missing_prefixes, + 'checker(s)': missing_checkers + } + + errors = [(name, lst) for name, lst in error_lists.items() if lst] + + if errors: + msg_template = Template( + "No $err_list_name with these names was found: $items.") + + for err_list_name, missing_items in errors: + missing_items_str = ', '.join(missing_items) + + diag_msg = msg_template.substitute(err_list_name=err_list_name, + items=missing_items_str) + + if 'no_missing_checker_error' in args: + LOG.warning(diag_msg) + else: + LOG.error(diag_msg) + + if 'no_missing_checker_error' not in args: + LOG.info("Although it is not recommended, if you want to " "suppress errors relating to unknown " "checker names, consider using the option " "'--no-missing-checker-error'")