Skip to content

Commit

Permalink
Merge pull request #4255 from bruntib/anywhere_in_cli
Browse files Browse the repository at this point in the history
[cmd] Add --anywhere-on-report-path flag to CLI
  • Loading branch information
bruntib authored Jun 7, 2024
2 parents 5e20cc1 + f3447b9 commit 686213a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 10 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
35 changes: 26 additions & 9 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 @@ -1416,8 +1427,11 @@ def handle_list_result_types(args):
init_logger(args.verbose if 'verbose' in args else None, stream)
check_deprecated_arg_usage(args)

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

setattr(report_filter, field, values)
checkers = client.getCheckerCounts(run_ids,
Expand Down Expand Up @@ -1454,21 +1468,24 @@ def checker_count(checker_dict, key):
all_checkers_dict = dict((res.name, res) for res in all_checkers)

unrev_checkers = get_statistics(client, run_ids, 'reviewStatus',
[ttypes.ReviewStatus.UNREVIEWED])
[ttypes.ReviewStatus.UNREVIEWED],
all_checkers_report_filter)

confirmed_checkers = get_statistics(client, run_ids, 'reviewStatus',
[ttypes.ReviewStatus.CONFIRMED])
[ttypes.ReviewStatus.CONFIRMED],
all_checkers_report_filter)

false_checkers = get_statistics(client, run_ids, 'reviewStatus',
[ttypes.ReviewStatus.FALSE_POSITIVE])
[ttypes.ReviewStatus.FALSE_POSITIVE],
all_checkers_report_filter)

intentional_checkers = get_statistics(client, run_ids, 'reviewStatus',
[ttypes.ReviewStatus.INTENTIONAL])
[ttypes.ReviewStatus.INTENTIONAL],
all_checkers_report_filter)

# 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 686213a

Please sign in to comment.