Skip to content

Commit

Permalink
[cmd] Add --anywhere-on-report-path flag to CLI
Browse files Browse the repository at this point in the history
The "anywhere on report path" feature exists in the web GUI. This
feature controls --component and --file filters in order to return
reports of which the report path not only ends in, but goes through
them.
In this commit this feature is added to the CLI, too.
  • Loading branch information
bruntib committed Jun 7, 2024
1 parent 5e20cc1 commit f51a9ea
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
4 changes: 4 additions & 0 deletions docs/web/user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,10 @@ filter arguments:
'year:month:day:hour:minute:second' (the "time" part
can be omitted, in which case midnight (00:00:00) is
used).
--anywhere-on-report-path
Filter reports where the report path not only ends in
the files given by --file or --component, but goes
through them. (default: False)
```

#### Source components (`components`)
Expand Down
12 changes: 11 additions & 1 deletion web/client/codechecker_client/cmd/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
DEFAULT_FILTER_VALUES = {
'review_status': ['unreviewed', 'confirmed'],
'detection_status': ['new', 'reopened', 'unresolved'],
'uniqueing': 'off'
'uniqueing': 'off',
'anywhere_on_report_path': False
}

DEFAULT_OUTPUT_FORMATS = ["plaintext"] + USER_FORMATS
Expand Down Expand Up @@ -424,6 +425,15 @@ def init_default(dest):
"\"time\" part can be omitted, in which case "
"midnight (00:00:00) is used).")

f_group.add_argument('--anywhere-on-report-path',
dest='anywhere_on_report_path',
required=False,
default=init_default('anywhere_on_report_path'),
action="store_true",
help="Filter reports where the report path not only "
"ends in the files given by --file or "
"--component, but goes through them.")


def __register_results(parser):
"""
Expand Down
18 changes: 14 additions & 4 deletions web/client/codechecker_client/cmd_line_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


from collections import defaultdict, namedtuple
from copy import deepcopy
from datetime import datetime, timedelta
import hashlib
import os
Expand Down Expand Up @@ -577,6 +578,16 @@ def parse_report_filter_offline(args):
if detected_at or fixed_at:
report_filter.date = ttypes.ReportDate(detected=detected_at,
fixed=fixed_at)

report_filter.fileMatchesAnyPoint = args.anywhere_on_report_path
report_filter.componentMatchesAnyPoint = args.anywhere_on_report_path

if args.anywhere_on_report_path and \
'file_path' not in args and 'component' not in args:
LOG.warning(
'The flag --anywhere-on-report-path is meaningful only if --file '
'or --component is used.')

return report_filter


Expand Down Expand Up @@ -1417,7 +1428,7 @@ def handle_list_result_types(args):
check_deprecated_arg_usage(args)

def get_statistics(client, run_ids, field, values):
report_filter = parse_report_filter(client, args)
report_filter = deepcopy(all_checkers_report_filter)

setattr(report_filter, field, values)
checkers = client.getCheckerCounts(run_ids,
Expand Down Expand Up @@ -1466,9 +1477,8 @@ def checker_count(checker_dict, key):
[ttypes.ReviewStatus.INTENTIONAL])

# Get severity counts
report_filter = parse_report_filter(client, args)

sev_count = client.getSeverityCounts(run_ids, report_filter, None)
sev_count = client.getSeverityCounts(
run_ids, all_checkers_report_filter, None)

severities = []
severity_total = 0
Expand Down

0 comments on commit f51a9ea

Please sign in to comment.