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

CodeChecker cmd runs #4468

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

CodeChecker cmd runs #4468

wants to merge 3 commits into from

Conversation

xb058t
Copy link
Collaborator

@xb058t xb058t commented Feb 24, 2025

This PR implements the feature requested in issue #4355

@xb058t xb058t force-pushed the cmd-runs branch 2 times, most recently from a83c3a5 to 6dc01b9 Compare February 24, 2025 18:50
Comment on lines +651 to +652
analyzers = info.checkers.keys()
for analyzer in analyzers:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
analyzers = info.checkers.keys()
for analyzer in analyzers:
for analyzer in info.checkers:

@@ -682,6 +725,7 @@ def handle_list_runs(args):
codechecker_version))

print(twodim.to_str(args.output_format, header, rows))
return
Copy link
Collaborator

Choose a reason for hiding this comment

The 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
return

print(twodim.to_str(args.output_format, header, rows))
else:
LOG.error("Unsupported output format: %s", args.output_format)
return
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding return here is totally unnecessary.

Suggested change
return

Comment on lines +643 to +682
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:
analyzers = info.checkers.keys()
for analyzer in analyzers:
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of introducing a separate if block for enabled_checkers handling, consider integrating it into the existing structure, similar to how 'details' is handled. This avoids redundant checks on args.output_format.
Additionally, rather than using direct print statements for plaintext and CSV formats, it would be better to use twodim.to_str() for consistency with the existing output formatting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants