diff --git a/web/client/codechecker_client/cli/cmd.py b/web/client/codechecker_client/cli/cmd.py index 6be5de36b6..44163a795b 100644 --- a/web/client/codechecker_client/cli/cmd.py +++ b/web/client/codechecker_client/cli/cmd.py @@ -1298,6 +1298,11 @@ def add_arguments_to_parser(parser): formatter_class=argparse.ArgumentDefaultsHelpFormatter, description="List the analysis runs available on the server.", help="List the available analysis runs.") + + runs.add_argument( + '--enabled-checkers', + action='store_true', + help='List all enabled checkers for the specified runs.') __register_runs(runs) runs.set_defaults(func=cmd_line_client.handle_list_runs) __add_common_arguments(runs, output_formats=DEFAULT_OUTPUT_FORMATS) diff --git a/web/client/codechecker_client/cmd_line_client.py b/web/client/codechecker_client/cmd_line_client.py index 7b526e0662..199295ee7a 100644 --- a/web/client/codechecker_client/cmd_line_client.py +++ b/web/client/codechecker_client/cmd_line_client.py @@ -19,6 +19,7 @@ import sys import shutil import time +import json from typing import Dict, Iterable, List, Optional, Set, Tuple from codechecker_api.codeCheckerDBAccess_v6 import constants, ttypes @@ -639,6 +640,47 @@ def handle_list_runs(args): runs = get_run_data(client, run_filter, sort_mode) + if hasattr(args, 'enabled_checkers') and args.enabled_checkers: + enabled_checkers: Dict[str, List[str]] = {} + for run in runs: + info_list: List[ttypes.AnalysisInfo] = client.getAnalysisInfo( + ttypes.AnalysisInfoFilter(runId=run.runId), + constants.MAX_QUERY_SIZE, + 0) + for info in info_list: + for analyzer in info.checkers: + if analyzer not in enabled_checkers: + enabled_checkers[analyzer] = [] + + checkers = info.checkers.get(analyzer, {}) + for checker in checkers: + if checkers[checker].enabled: + enabled_checkers[analyzer].append(checker) + + if args.output_format == 'plaintext': + for analyzer, checkers in enabled_checkers.items(): + print(analyzer + ":") + for checker in checkers: + print(" " + checker) + elif args.output_format == 'csv': + separator = ';' + print("Analyzer" + separator + "Checker") + for analyzer, checkers in enabled_checkers.items(): + for checker in checkers: + print(analyzer + separator + checker) + elif args.output_format == 'json': + print(json.dumps(enabled_checkers, indent=4)) + elif args.output_format == 'table': + header = ['Analyzer', 'Checker'] + rows = [ + (analyzer, checker) + for analyzer, checkers in enabled_checkers.items() + for checker in checkers] + print(twodim.to_str(args.output_format, header, rows)) + else: + LOG.error("Unsupported output format: %s", args.output_format) + return + if args.output_format == 'json': # This json is different from the json format printed by the # parse command. This json converts the ReportData type report @@ -682,6 +724,7 @@ def handle_list_runs(args): codechecker_version)) print(twodim.to_str(args.output_format, header, rows)) + return def handle_list_results(args): diff --git a/web/client/codechecker_client/helpers/results.py b/web/client/codechecker_client/helpers/results.py index c558cfe040..ee4b1ee0b6 100644 --- a/web/client/codechecker_client/helpers/results.py +++ b/web/client/codechecker_client/helpers/results.py @@ -196,3 +196,7 @@ def getAnalysisStatistics(self, run_id, run_history_id): @thrift_client_call def storeAnalysisStatistics(self, run_name, zip_file): pass + + @thrift_client_call + def getAnalysisInfo(self, analysis_info_filter, limit, offset): + pass