diff --git a/docs/user_guide.md b/docs/user_guide.md index 094879b0f6..4f2467ba2b 100644 --- a/docs/user_guide.md +++ b/docs/user_guide.md @@ -1281,14 +1281,18 @@ positional arguments: optional arguments: -h, --help show this help message and exit - -s, --suppressed Show only suppressed results instead of only - unsuppressed ones. (default: False) + -s, --suppressed DEPRECATED. Use the '--filter' option to get false + positive (suppressed) results. Show only suppressed + results instead of only unsuppressed ones. --filter FILTER Filter results. The filter string has the following format: - []:[]:[] where - severites, checker_names, file_paths should be a comma + []:[]:[]: + []:[] where + severites, checker_names, file_paths, + detection_statuses and review_statuses should be a comma separated list, e.g.: - "high,medium:unix,core:*.cpp,*.h" (default: ::) + "high,medium:unix,core:*.cpp,*.h:new,unresolved: + false_positive,intentional" (default: ::) ~~~~~~~~~~~~~~~~~~~~~ ### Show differences between two runs (`diff`) diff --git a/libcodechecker/cmd/cmd_line_client.py b/libcodechecker/cmd/cmd_line_client.py index d9e2862775..007296149b 100644 --- a/libcodechecker/cmd/cmd_line_client.py +++ b/libcodechecker/cmd/cmd_line_client.py @@ -87,13 +87,14 @@ def add_filter_conditions(report_filter, filter_str): the checker id doesn't have to be complete (e.g. unix). """ - if filter_str.count(':') != 2: - LOG.error("Filter string has to contain two colons (e.g. " - "\"high,medium:unix,core:*.cpp\").") + if filter_str.count(':') != 4: + LOG.error("Filter string has to contain four colons (e.g. " + "\"high,medium:unix,core:*.cpp:new,unresolved:" + "false_positive,intentional\").") sys.exit(1) - severities, checkers, paths = map(lambda x: x.strip(), - filter_str.split(':')) + severities, checkers, paths, dt_statuses, rw_statuses = \ + map(lambda x: x.strip(), filter_str.split(':')) if severities: report_filter.severity = map( @@ -106,6 +107,16 @@ def add_filter_conditions(report_filter, filter_str): report_filter.filepath = map(lambda x: '*' + x + '*', paths.split(',')) + if dt_statuses: + report_filter.detectionStatus = map( + lambda x: ttypes.DetectionStatus._NAMES_TO_VALUES[x.upper()], + dt_statuses.split(',')) + + if rw_statuses: + report_filter.reviewStatus = map( + lambda x: ttypes.ReviewStatus._NAMES_TO_VALUES[x.upper()], + rw_statuses.split(',')) + # --------------------------------------------------------------------------- # Argument handlers for the 'CodeChecker cmd' subcommands. # --------------------------------------------------------------------------- @@ -163,24 +174,21 @@ def handle_list_results(args): if args.output_format == 'json': print(CmdLineOutputEncoder().encode(all_results)) else: - - if args.suppressed: - header = ['File', 'Checker', 'Severity', 'Msg', 'Suppress comment'] - else: - header = ['File', 'Checker', 'Severity', 'Msg'] + header = ['File', 'Checker', 'Severity', 'Msg', 'Review status', + 'Detection status'] rows = [] for res in all_results: bug_line = res.line checked_file = res.checkedFile + ' @ ' + str(bug_line) sev = ttypes.Severity._VALUES_TO_NAMES[res.severity] + rw_status = \ + ttypes.ReviewStatus._VALUES_TO_NAMES[res.reviewData.status] + dt_status = \ + ttypes.DetectionStatus._VALUES_TO_NAMES[res.detectionStatus] - if args.suppressed: - rows.append((checked_file, res.checkerId, sev, - res.checkerMsg, res.suppressComment)) - else: - rows.append( - (checked_file, res.checkerId, sev, res.checkerMsg)) + rows.append((checked_file, res.checkerId, sev, + res.checkerMsg, rw_status, dt_status)) print(twodim_to_str(args.output_format, header, rows)) diff --git a/libcodechecker/libhandlers/cmd.py b/libcodechecker/libhandlers/cmd.py index ce1605ac54..9d6f191010 100644 --- a/libcodechecker/libhandlers/cmd.py +++ b/libcodechecker/libhandlers/cmd.py @@ -132,23 +132,27 @@ def __add_filtering_arguments(parser): Add some common filtering arguments to the given parser. """ - # TODO: '-s' does not mean suppressed anymore in any other command. parser.add_argument('-s', '--suppressed', dest="suppressed", action='store_true', - help="Show only suppressed results instead of only " - "unsuppressed ones.") + help="DEPRECATED. Use the '--filter' option to get " + "false positive (suppressed) results. Show only " + "suppressed results instead of only unsuppressed " + "ones.") parser.add_argument('--filter', type=str, dest='filter', - default="::", + default="::::", help="Filter results. The filter string has the " "following format: " - "[]:[]:[] " + "[]:[]:[]:" + "[]:[]" "where severites, checker_names, " - "file_paths should be a comma separated list, " - "e.g.: \"high,medium:unix,core:*.cpp,*.h\"") + "file_paths, detection_statuses, review_statuses " + "should be a comma separated list, e.g.:" + "\"high,medium:unix,core:*.cpp,*.h:" + "new,unresolved:false_positive,intentional\"") def __register_results(parser):