[config] Rename `filter-report` command to `censor-report` and stop reporting them on console and bugs.txt

Summary:
- Rename `filter-report` command to `censor-report`and update comments
- Stop reporting censored issues on the console and in `bugs.txt`

Reviewed By: jvillard

Differential Revision: D16540525

fbshipit-source-id: f5f7dcea3
master
Ezgi Çiçek 5 years ago committed by Facebook Github Bot
parent b3f52284ed
commit e320d8a580

@ -31,6 +31,7 @@ ISSUE_SEVERITY_ADVICE = 'ADVICE'
ISSUE_SEVERITY_LIKE = 'LIKE' ISSUE_SEVERITY_LIKE = 'LIKE'
# field names in rows of json reports # field names in rows of json reports
JSON_INDEX_CENSORED_REASON = 'censored_reason'
JSON_INDEX_DOTTY = 'dotty' JSON_INDEX_DOTTY = 'dotty'
JSON_INDEX_FILENAME = 'file' JSON_INDEX_FILENAME = 'file'
JSON_INDEX_HASH = 'hash' JSON_INDEX_HASH = 'hash'
@ -177,12 +178,18 @@ def _text_of_report_list(project_root, reports, bugs_txt_path, limit=None,
return bug_list + summary return bug_list + summary
def _get_censored_reason(report):
return report.get(JSON_INDEX_CENSORED_REASON)
def _is_user_visible(report): def _is_user_visible(report):
return report[JSON_INDEX_SEVERITY] in [ if _get_censored_reason(report) is not None:
ISSUE_SEVERITY_ERROR, return False
ISSUE_SEVERITY_WARNING, else:
ISSUE_SEVERITY_ADVICE, return report[JSON_INDEX_SEVERITY] in [
ISSUE_SEVERITY_LIKE] ISSUE_SEVERITY_ERROR,
ISSUE_SEVERITY_WARNING,
ISSUE_SEVERITY_ADVICE,
ISSUE_SEVERITY_LIKE]
def print_and_save_errors(infer_out, project_root, json_report, bugs_out, def print_and_save_errors(infer_out, project_root, json_report, bugs_out,

@ -163,6 +163,26 @@ OPTIONS
expression (only supported by the javac integration for now). expression (only supported by the javac integration for now).
See also infer-capture(1) and infer-run(1). See also infer-capture(1) and infer-run(1).
--censor-report +string
Specify a filter for issues to be censored by adding a
'censored_reason' field in the json report. Infer will not report
censored issues on the console output and in bugs.txt, but tools
that post-process the json report can take them into account. If
multiple filters are specified, they are applied in the order in
which they are specified. Each filter is applied to each issue
detected, and only issues which are accepted by all filters are
reported. Each filter is of the form:
`<issue_type_regex>:<filename_regex>:<reason_string>`. The first
two components are OCaml Str regular expressions, with an optional
`!` character prefix. If a regex has a `!` prefix, the polarity is
inverted, and the filter becomes a "blacklist" instead of a
"whitelist". Each filter is interpreted as an implication: an
issue matches if it does not match the `issue_type_regex` or if it
does match the `filename_regex`. The filenames that are tested by
the regex are relative to the `--project-root` directory. The
`<reason_string>` is a non-empty string used to explain why the
issue was filtered. See also infer-report(1) and infer-run(1).
--changed-files-index file --changed-files-index file
Specify the file containing the list of source files from which Specify the file containing the list of source files from which
reactive analysis should start. Source files should be specified reactive analysis should start. Source files should be specified
@ -514,23 +534,6 @@ OPTIONS
JSON with a list of file renamings to use while computing JSON with a list of file renamings to use while computing
differential reports See also infer-reportdiff(1). differential reports See also infer-reportdiff(1).
--filter-report +string
Specify a filter for issues to report. If multiple filters are
specified, they are applied in the order in which they are
specified. Each filter is applied to each issue detected, and only
issues which are accepted by all filters are reported. Each filter
is of the form:
`<issue_type_regex>:<filename_regex>:<reason_string>`. The first
two components are OCaml Str regular expressions, with an optional
`!` character prefix. If a regex has a `!` prefix, the polarity is
inverted, and the filter becomes a "blacklist" instead of a
"whitelist". Each filter is interpreted as an implication: an
issue matches if it does not match the `issue_type_regex` or if it
does match the `filename_regex`. The filenames that are tested by
the regex are relative to the `--project-root` directory. The
`<reason_string>` is a non-empty string used to explain why the
issue was filtered. See also infer-report(1) and infer-run(1).
--no-filtering,-F --no-filtering,-F
Deactivates: Do not show the experimental and blacklisted issue Deactivates: Do not show the experimental and blacklisted issue
types (Conversely: --filtering | -f) See also infer-report(1). types (Conversely: --filtering | -f) See also infer-report(1).
@ -1184,6 +1187,9 @@ INTERNAL OPTIONS
--capture-blacklist-reset --capture-blacklist-reset
Cancel the effect of --capture-blacklist. Cancel the effect of --capture-blacklist.
--censor-report-reset
Set --censor-report to the empty list.
--changed-files-index-reset --changed-files-index-reset
Cancel the effect of --changed-files-index. Cancel the effect of --changed-files-index.
@ -1355,9 +1361,6 @@ INTERNAL OPTIONS
Deactivates: Filters specified in .inferconfig (Conversely: Deactivates: Filters specified in .inferconfig (Conversely:
--filter-paths) --filter-paths)
--filter-report-reset
Set --filter-report to the empty list.
--force-integration-reset --force-integration-reset
Cancel the effect of --force-integration. Cancel the effect of --force-integration.

@ -15,6 +15,26 @@ DESCRIPTION
OPTIONS OPTIONS
--censor-report +string
Specify a filter for issues to be censored by adding a
'censored_reason' field in the json report. Infer will not report
censored issues on the console output and in bugs.txt, but tools
that post-process the json report can take them into account. If
multiple filters are specified, they are applied in the order in
which they are specified. Each filter is applied to each issue
detected, and only issues which are accepted by all filters are
reported. Each filter is of the form:
`<issue_type_regex>:<filename_regex>:<reason_string>`. The first
two components are OCaml Str regular expressions, with an optional
`!` character prefix. If a regex has a `!` prefix, the polarity is
inverted, and the filter becomes a "blacklist" instead of a
"whitelist". Each filter is interpreted as an implication: an
issue matches if it does not match the `issue_type_regex` or if it
does match the `filename_regex`. The filenames that are tested by
the regex are relative to the `--project-root` directory. The
`<reason_string>` is a non-empty string used to explain why the
issue was filtered.
--debug,-g --debug,-g
Activates: Debug mode (also sets --debug-level 2, Activates: Debug mode (also sets --debug-level 2,
--developer-mode, --no-filtering, --print-buckets, --print-types, --developer-mode, --no-filtering, --print-buckets, --print-types,
@ -227,23 +247,6 @@ OPTIONS
checker run; see individual checker options to turn them on or checker run; see individual checker options to turn them on or
off. off.
--filter-report +string
Specify a filter for issues to report. If multiple filters are
specified, they are applied in the order in which they are
specified. Each filter is applied to each issue detected, and only
issues which are accepted by all filters are reported. Each filter
is of the form:
`<issue_type_regex>:<filename_regex>:<reason_string>`. The first
two components are OCaml Str regular expressions, with an optional
`!` character prefix. If a regex has a `!` prefix, the polarity is
inverted, and the filter becomes a "blacklist" instead of a
"whitelist". Each filter is interpreted as an implication: an
issue matches if it does not match the `issue_type_regex` or if it
does match the `filename_regex`. The filenames that are tested by
the regex are relative to the `--project-root` directory. The
`<reason_string>` is a non-empty string used to explain why the
issue was filtered.
--no-filtering,-F --no-filtering,-F
Deactivates: Do not show the experimental and blacklisted issue Deactivates: Do not show the experimental and blacklisted issue
types (Conversely: --filtering | -f) types (Conversely: --filtering | -f)

@ -16,6 +16,26 @@ DESCRIPTION
OPTIONS OPTIONS
--censor-report +string
Specify a filter for issues to be censored by adding a
'censored_reason' field in the json report. Infer will not report
censored issues on the console output and in bugs.txt, but tools
that post-process the json report can take them into account. If
multiple filters are specified, they are applied in the order in
which they are specified. Each filter is applied to each issue
detected, and only issues which are accepted by all filters are
reported. Each filter is of the form:
`<issue_type_regex>:<filename_regex>:<reason_string>`. The first
two components are OCaml Str regular expressions, with an optional
`!` character prefix. If a regex has a `!` prefix, the polarity is
inverted, and the filter becomes a "blacklist" instead of a
"whitelist". Each filter is interpreted as an implication: an
issue matches if it does not match the `issue_type_regex` or if it
does match the `filename_regex`. The filenames that are tested by
the regex are relative to the `--project-root` directory. The
`<reason_string>` is a non-empty string used to explain why the
issue was filtered.
--debug,-g --debug,-g
Activates: Debug mode (also sets --debug-level 2, Activates: Debug mode (also sets --debug-level 2,
--developer-mode, --no-filtering, --print-buckets, --print-types, --developer-mode, --no-filtering, --print-buckets, --print-types,
@ -45,23 +65,6 @@ OPTIONS
Activates: Exit with error code 2 if Infer found something to Activates: Exit with error code 2 if Infer found something to
report (Conversely: --no-fail-on-issue) report (Conversely: --no-fail-on-issue)
--filter-report +string
Specify a filter for issues to report. If multiple filters are
specified, they are applied in the order in which they are
specified. Each filter is applied to each issue detected, and only
issues which are accepted by all filters are reported. Each filter
is of the form:
`<issue_type_regex>:<filename_regex>:<reason_string>`. The first
two components are OCaml Str regular expressions, with an optional
`!` character prefix. If a regex has a `!` prefix, the polarity is
inverted, and the filter becomes a "blacklist" instead of a
"whitelist". Each filter is interpreted as an implication: an
issue matches if it does not match the `issue_type_regex` or if it
does match the `filename_regex`. The filenames that are tested by
the regex are relative to the `--project-root` directory. The
`<reason_string>` is a non-empty string used to explain why the
issue was filtered.
--force-delete-results-dir --force-delete-results-dir
Activates: Do not refuse to delete the results directory if it Activates: Do not refuse to delete the results directory if it
doesn't look like an infer results directory. (Conversely: doesn't look like an infer results directory. (Conversely:

@ -163,6 +163,26 @@ OPTIONS
expression (only supported by the javac integration for now). expression (only supported by the javac integration for now).
See also infer-capture(1) and infer-run(1). See also infer-capture(1) and infer-run(1).
--censor-report +string
Specify a filter for issues to be censored by adding a
'censored_reason' field in the json report. Infer will not report
censored issues on the console output and in bugs.txt, but tools
that post-process the json report can take them into account. If
multiple filters are specified, they are applied in the order in
which they are specified. Each filter is applied to each issue
detected, and only issues which are accepted by all filters are
reported. Each filter is of the form:
`<issue_type_regex>:<filename_regex>:<reason_string>`. The first
two components are OCaml Str regular expressions, with an optional
`!` character prefix. If a regex has a `!` prefix, the polarity is
inverted, and the filter becomes a "blacklist" instead of a
"whitelist". Each filter is interpreted as an implication: an
issue matches if it does not match the `issue_type_regex` or if it
does match the `filename_regex`. The filenames that are tested by
the regex are relative to the `--project-root` directory. The
`<reason_string>` is a non-empty string used to explain why the
issue was filtered. See also infer-report(1) and infer-run(1).
--changed-files-index file --changed-files-index file
Specify the file containing the list of source files from which Specify the file containing the list of source files from which
reactive analysis should start. Source files should be specified reactive analysis should start. Source files should be specified
@ -514,23 +534,6 @@ OPTIONS
JSON with a list of file renamings to use while computing JSON with a list of file renamings to use while computing
differential reports See also infer-reportdiff(1). differential reports See also infer-reportdiff(1).
--filter-report +string
Specify a filter for issues to report. If multiple filters are
specified, they are applied in the order in which they are
specified. Each filter is applied to each issue detected, and only
issues which are accepted by all filters are reported. Each filter
is of the form:
`<issue_type_regex>:<filename_regex>:<reason_string>`. The first
two components are OCaml Str regular expressions, with an optional
`!` character prefix. If a regex has a `!` prefix, the polarity is
inverted, and the filter becomes a "blacklist" instead of a
"whitelist". Each filter is interpreted as an implication: an
issue matches if it does not match the `issue_type_regex` or if it
does match the `filename_regex`. The filenames that are tested by
the regex are relative to the `--project-root` directory. The
`<reason_string>` is a non-empty string used to explain why the
issue was filtered. See also infer-report(1) and infer-run(1).
--no-filtering,-F --no-filtering,-F
Deactivates: Do not show the experimental and blacklisted issue Deactivates: Do not show the experimental and blacklisted issue
types (Conversely: --filtering | -f) See also infer-report(1). types (Conversely: --filtering | -f) See also infer-report(1).

@ -173,7 +173,7 @@ let censored_reason (issue_type : IssueType.t) source_file =
in in
Option.some_if (not accepted) reason Option.some_if (not accepted) reason
in in
List.find_map Config.filter_report ~f:rejected_by List.find_map Config.censor_report ~f:rejected_by
let potential_exception_message = "potential exception at line" let potential_exception_message = "potential exception at line"

@ -922,6 +922,23 @@ and capture_blacklist =
the javac integration for now)." the javac integration for now)."
and censor_report =
CLOpt.mk_string_list ~long:"censor-report" ~deprecated:["-filter-report"]
~in_help:InferCommand.[(Report, manual_generic); (Run, manual_generic)]
"Specify a filter for issues to be censored by adding a 'censored_reason' field in the json \
report. Infer will not report censored issues on the console output and in bugs.txt, but \
tools that post-process the json report can take them into account. If multiple filters are \
specified, they are applied in the order in which they are specified. Each filter is applied \
to each issue detected, and only issues which are accepted by all filters are reported. Each \
filter is of the form: `<issue_type_regex>:<filename_regex>:<reason_string>`. The first two \
components are OCaml Str regular expressions, with an optional `!` character prefix. If a \
regex has a `!` prefix, the polarity is inverted, and the filter becomes a \"blacklist\" \
instead of a \"whitelist\". Each filter is interpreted as an implication: an issue matches \
if it does not match the `issue_type_regex` or if it does match the `filename_regex`. The \
filenames that are tested by the regex are relative to the `--project-root` directory. The \
`<reason_string>` is a non-empty string used to explain why the issue was filtered."
and changed_files_index = and changed_files_index =
CLOpt.mk_path_opt ~long:"changed-files-index" CLOpt.mk_path_opt ~long:"changed-files-index"
~in_help:InferCommand.[(Analyze, manual_generic); (Diff, manual_generic)] ~in_help:InferCommand.[(Analyze, manual_generic); (Diff, manual_generic)]
@ -1401,21 +1418,6 @@ and filter_paths =
CLOpt.mk_bool ~long:"filter-paths" ~default:true "Filters specified in .inferconfig" CLOpt.mk_bool ~long:"filter-paths" ~default:true "Filters specified in .inferconfig"
and filter_report =
CLOpt.mk_string_list ~long:"filter-report"
~in_help:InferCommand.[(Report, manual_generic); (Run, manual_generic)]
"Specify a filter for issues to report. If multiple filters are specified, they are applied \
in the order in which they are specified. Each filter is applied to each issue detected, and \
only issues which are accepted by all filters are reported. Each filter is of the form: \
`<issue_type_regex>:<filename_regex>:<reason_string>`. The first two components are OCaml \
Str regular expressions, with an optional `!` character prefix. If a regex has a `!` prefix, \
the polarity is inverted, and the filter becomes a \"blacklist\" instead of a \"whitelist\". \
Each filter is interpreted as an implication: an issue matches if it does not match the \
`issue_type_regex` or if it does match the `filename_regex`. The filenames that are tested \
by the regex are relative to the `--project-root` directory. The `<reason_string>` is a \
non-empty string used to explain why the issue was filtered."
and flavors = and flavors =
CLOpt.mk_bool ~deprecated:["-use-flavors"] ~long:"flavors" CLOpt.mk_bool ~deprecated:["-use-flavors"] ~long:"flavors"
~in_help:InferCommand.[(Capture, manual_buck_flavors)] ~in_help:InferCommand.[(Capture, manual_buck_flavors)]
@ -2731,6 +2733,21 @@ and capture =
and capture_blacklist = !capture_blacklist and capture_blacklist = !capture_blacklist
and censor_report =
List.map !censor_report ~f:(fun str ->
match String.split str ~on:':' with
| [issue_type_re; filename_re; reason_str]
when not String.(is_empty issue_type_re || is_empty filename_re || is_empty reason_str) ->
let polarity_regex re =
let polarity = not (Char.equal '!' re.[0]) in
let regex = Str.regexp (if polarity then re else String.slice re 1 0) in
(polarity, regex)
in
(polarity_regex issue_type_re, polarity_regex filename_re, reason_str)
| _ ->
L.(die UserError) "Ill-formed report filter: %s" str )
and changed_files_index = !changed_files_index and changed_files_index = !changed_files_index
and nullsafe = !nullsafe and nullsafe = !nullsafe
@ -2827,21 +2844,6 @@ and file_renamings = !file_renamings
and filter_paths = !filter_paths and filter_paths = !filter_paths
and filter_report =
List.map !filter_report ~f:(fun str ->
match String.split str ~on:':' with
| [issue_type_re; filename_re; reason_str]
when not String.(is_empty issue_type_re || is_empty filename_re || is_empty reason_str) ->
let polarity_regex re =
let polarity = not (Char.equal '!' re.[0]) in
let regex = Str.regexp (if polarity then re else String.slice re 1 0) in
(polarity, regex)
in
(polarity_regex issue_type_re, polarity_regex filename_re, reason_str)
| _ ->
L.(die UserError) "Ill-formed report filter: %s" str )
and filtering = !filtering and filtering = !filtering
and flavors = !flavors and flavors = !flavors

@ -268,6 +268,8 @@ val capture_blacklist : string option
val captured_dir : string val captured_dir : string
(** directory where the results of the capture phase are stored *) (** directory where the results of the capture phase are stored *)
val censor_report : ((bool * Str.regexp) * (bool * Str.regexp) * string) list
val changed_files_index : string option val changed_files_index : string option
val check_version : string option val check_version : string option
@ -364,8 +366,6 @@ val file_renamings : string option
val filter_paths : bool val filter_paths : bool
val filter_report : ((bool * Str.regexp) * (bool * Str.regexp) * string) list
val filtering : bool val filtering : bool
val flavors : bool val flavors : bool

Loading…
Cancel
Save