-
Notifications
You must be signed in to change notification settings - Fork 458
List enabled checkers in CLI: CodeChecker cmd runs #4468
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
Changes from 5 commits
73ff6af
3ec795f
7787aa9
9d63a86
27704e2
1d6697f
25bb553
0936c70
28bb6a9
d24cb1d
5998c90
4c1b942
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -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) | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, use the standard |
||||
| 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 | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding return here is totally unnecessary.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @xb058t Please do as @cservakt suggested and merge the enabled-checkers processing starting at line 684. Also please add the enabled checkers list when [INFO 2026-02-13 15:50] - Checking for local valid sessions. |
||||
|
|
||||
| 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 | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The explicit 'return' at the end of the function is unnecessary in Python.
Suggested change
|
||||
|
|
||||
|
|
||||
| def handle_list_results(args): | ||||
|
|
||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if the introduction of this new flag is a good idea. If no run name is specified, then the current implementation lists the union of all checkers enabled in any of the runs:
CodeChecker cmd runs --enabled-checkersWhat is the use of such a query? At least the
--nameflag should be mandatoryI would say that the list of enabled checkers belongs to the given runs, so they should be listed per run. The default output format of
CodeChecker cmd runsis an ASCII-art table that is not convenient to display this long information. My suggestion is to put this checker list in the JSON format only as @dkrupp mentioned.The following functional test could be extended to test this feature in entirety:
codechecker/web/tests/functional/cmdline/test_cmdline.py
Line 224 in 463081e
Ps.:
In a later and independent discussion we could talk about whether
--detailsflag and other output formats like plaintext, table (these are the same, by the way), csv, etc. are necessary.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After discussing with @bruntib we have the following proposal:
Remove the
--detailsflag and the--enabled-checkersflags from theCodeChecker cmd runscommand.The enabled checker list should always be printed in the
-o jsonmode, but not in theplaintext,csv, andtablemodes.So the user would use the command like
CodeChecker cmd runs -n <run_name>or without the run name selector, likeCodeChecker cmd runswhen all runs are printed.Make sure that the json output is not null for any fields like
runCmd.The json format is okay like this
Make sure that the json output is indented properly.