add various filter options from inferconfig to the CLI

Summary:
Part of the migration of .inferconfig-specific options into options accepted
both by .inferconfig and the CLI.

Reviewed By: jberdine

Differential Revision: D3304783

fbshipit-source-id: 4a7ee6f
master
Jules Villard 9 years ago committed by Facebook Github Bot 4
parent 3fe032ccf0
commit e695e14ee1

@ -324,7 +324,11 @@ let decode_inferconfig_to_argv path =
let json_config = YBU.to_assoc json in
let one_config_item result (key, json_val) =
try
let {decode_json} = IList.find (fun {long} -> string_equal key long) desc_list in
let {decode_json} =
IList.find
(fun {long; short} ->
string_equal key long || (* for deprecated options *) string_equal key short)
desc_list in
decode_json json_val @ result
with
| Not_found ->

@ -269,6 +269,41 @@ and allow_specs_cleanup =
CLOpt.mk_bool ~deprecated:["allow_specs_cleanup"] ~long:"allow-specs-cleanup"
"Allow to remove existing specs before running analysis when it's not incremental"
and (
analysis_path_regex_whitelist_options,
analysis_path_regex_blacklist_options,
analysis_blacklist_files_containing_options,
analysis_suppress_errors_options) =
let mk_filtering_options ~suffix ?(deprecated_suffix=[]) ~help ~meta =
let mk_option analyzer =
let long = Printf.sprintf "%s-%s" (string_of_analyzer analyzer) suffix in
let deprecated =
IList.map (Printf.sprintf "%s_%s" (string_of_analyzer analyzer)) deprecated_suffix in
let help_string = Printf.sprintf "%s (%s only)" help (string_of_analyzer analyzer) in
CLOpt.mk_string_list ~deprecated ~long ~exes:CLOpt.[A] ~meta help_string in
IList.map (fun analyzer -> (analyzer, mk_option analyzer)) analyzers in
(
mk_filtering_options
~suffix:"whitelist-path-regex"
~deprecated_suffix:["whitelist"]
~help:"whitelist the analysis of files whose relative path matches the specified OCaml-style regex"
~meta:"path regex",
mk_filtering_options
~suffix:"blacklist-path-regex"
~deprecated_suffix:["blacklist"]
~help:"blacklist the analysis of files whose relative path matches the specified OCaml-style regex"
~meta:"path regex",
mk_filtering_options
~suffix:"blacklist-files-containing"
~deprecated_suffix:["blacklist_files_containing"]
~help:"blacklist files containing the specified string"
~meta:"string",
mk_filtering_options
~suffix:"suppress-errors"
~deprecated_suffix:["suppress_errors"]
~help:"do not report a type of errors"
~meta:"error name")
(** Check whether to report Analysis_stops message in user mode *)
and analysis_stops =
CLOpt.mk_bool ~deprecated:["analysis_stops"] ~long:"analysis-stops"
@ -969,6 +1004,14 @@ let print_usage_exit () =
let anon_args = !anon_args
and abs_struct = !abs_struct
and allow_specs_cleanup = !allow_specs_cleanup
and analysis_path_regex_whitelist_options =
IList.map (fun (a, b) -> (a, !b)) analysis_path_regex_whitelist_options
and analysis_path_regex_blacklist_options =
IList.map (fun (a, b) -> (a, !b)) analysis_path_regex_blacklist_options
and analysis_blacklist_files_containing_options =
IList.map (fun (a, b) -> (a, !b)) analysis_blacklist_files_containing_options
and analysis_suppress_errors_options =
IList.map (fun (a, b) -> (a, !b)) analysis_suppress_errors_options
and analysis_stops = !analysis_stops
and analyzer = !analyzer
and angelic_execution = !angelic_execution
@ -1055,6 +1098,16 @@ and write_html = !write_html
and xml_specs = !xml_specs
and zip_libraries = !zip_libraries
let analysis_path_regex_whitelist analyzer =
IList.assoc (=) analyzer analysis_path_regex_whitelist_options
and analysis_path_regex_blacklist analyzer =
IList.assoc (=) analyzer analysis_path_regex_blacklist_options
and analysis_blacklist_files_containing analyzer =
IList.assoc (=) analyzer analysis_blacklist_files_containing_options
and analysis_suppress_errors analyzer =
IList.assoc (=) analyzer analysis_suppress_errors_options
let inferconfig_json = lazy !CLOpt.inferconfig_json
and suppress_warnings_json = lazy (

@ -101,7 +101,11 @@ val sound_dynamic_dispatch : bool
val anon_args : string list
val abs_struct : int
val allow_specs_cleanup : bool
val analysis_path_regex_whitelist : analyzer -> string list
val analysis_path_regex_blacklist : analyzer -> string list
val analysis_blacklist_files_containing : analyzer -> string list
val analysis_stops : bool
val analysis_suppress_errors : analyzer -> string list
val analyzer : analyzer option
val angelic_execution : bool
val array_level : int

@ -327,16 +327,12 @@ module ModeledExpensiveMatcher = OverridesMatcher(struct
end)
let load_filters analyzer =
let lazy json = Config.inferconfig_json in
let inferconfig =
{
whitelist = lookup_string_list (analyzer ^ "_whitelist") json;
blacklist = lookup_string_list (analyzer ^ "_blacklist") json;
blacklist_files_containing =
lookup_string_list (analyzer ^ "_blacklist_files_containing") json;
suppress_errors = lookup_string_list (analyzer ^ "_suppress_errors") json;
} in
Some inferconfig
{
whitelist = Config.analysis_path_regex_whitelist analyzer;
blacklist = Config.analysis_path_regex_blacklist analyzer;
blacklist_files_containing = Config.analysis_blacklist_files_containing analyzer;
suppress_errors = Config.analysis_suppress_errors analyzer;
}
let filters_from_inferconfig inferconfig : filters =
let path_filter =
@ -365,10 +361,7 @@ let filters_from_inferconfig inferconfig : filters =
(* The environment varialble NO_PATH_FILTERING disables path filtering. *)
let create_filters analyzer =
if Config.from_env_variable "NO_PATH_FILTERING" then do_not_filter
else
match load_filters (Utils.string_of_analyzer analyzer) with
| None -> do_not_filter
| Some inferconfig -> filters_from_inferconfig inferconfig
else filters_from_inferconfig (load_filters analyzer)
(* Decide whether a checker or error type is enabled or disabled based on*)
(* white/black listing in .inferconfig and the default value *)

@ -10,7 +10,7 @@
"method": "get"
}
],
"infer_blacklist_files_containing": [
"infer-blacklist-files-containing": [
"@generated"
],
"skip_translation": [

Loading…
Cancel
Save