add {enable,disable}_checks 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: D3304785

fbshipit-source-id: e0204e9
master
Jules Villard 9 years ago committed by Facebook Github Bot 8
parent 8f154144c0
commit 9748a8f1a3

@ -427,11 +427,19 @@ and developer_mode =
~default:(CLOpt.current_exe = CLOpt.P) ~default:(CLOpt.current_exe = CLOpt.P)
"Reserved" "Reserved"
and disable_checks =
CLOpt.mk_string_list ~deprecated:["disable_checks"] ~long:"disable-checks" ~meta:"error name"
"do not show reports coming from this type of errors"
(** if true, print cfg nodes in the dot file that are not defined in that file *) (** if true, print cfg nodes in the dot file that are not defined in that file *)
and dotty_cfg_libs = and dotty_cfg_libs =
CLOpt.mk_bool ~deprecated:["dotty_no_cfg_libs"] ~long:"dotty-cfg-libs" ~default:true CLOpt.mk_bool ~deprecated:["dotty_no_cfg_libs"] ~long:"dotty-cfg-libs" ~default:true
"Prints the cfg of the code coming from the libraries" "Prints the cfg of the code coming from the libraries"
and enable_checks =
CLOpt.mk_string_list ~deprecated:["enable_checks"] ~long:"enable-checks" ~meta:"error name"
"show reports coming from this type of errors"
(** command line option to activate the eradicate checker. *) (** command line option to activate the eradicate checker. *)
and eradicate, checkers = and eradicate, checkers =
(** command line option: if true, run the analysis in checker mode *) (** command line option: if true, run the analysis in checker mode *)
@ -1043,7 +1051,9 @@ and cxx_experimental = !cxx_experimental
and debug_mode = !debug and debug_mode = !debug
and dependency_mode = !dependencies and dependency_mode = !dependencies
and developer_mode = !developer_mode and developer_mode = !developer_mode
and disable_checks = !disable_checks
and dotty_cfg_libs = !dotty_cfg_libs and dotty_cfg_libs = !dotty_cfg_libs
and enable_checks = !enable_checks
and eradicate = !eradicate and eradicate = !eradicate
and err_file_cmdline = !err_file and err_file_cmdline = !err_file
and infer_cache = !infer_cache and infer_cache = !infer_cache

@ -126,7 +126,9 @@ val cxx_experimental : bool
val debug_mode : bool val debug_mode : bool
val dependency_mode : bool val dependency_mode : bool
val developer_mode : bool val developer_mode : bool
val disable_checks : string list
val dotty_cfg_libs : bool val dotty_cfg_libs : bool
val enable_checks : string list
val eradicate : bool val eradicate : bool
val err_file_cmdline : string val err_file_cmdline : string
val infer_cache : string option val infer_cache : string option

@ -11,14 +11,6 @@ open! Utils
module L = Logging module L = Logging
(** Look up a key in a json file containing a list of strings *)
let lookup_string_list key json =
try
Yojson.Basic.Util.filter_member key [json]
|> Yojson.Basic.Util.flatten
|> Yojson.Basic.Util.filter_string
with Yojson.Basic.Util.Type_error _ -> []
type path_filter = DB.source_file -> bool type path_filter = DB.source_file -> bool
type error_filter = Localise.t -> bool type error_filter = Localise.t -> bool
type proc_filter = Procname.t -> bool type proc_filter = Procname.t -> bool
@ -365,15 +357,9 @@ let create_filters analyzer =
(* Decide whether a checker or error type is enabled or disabled based on*) (* Decide whether a checker or error type is enabled or disabled based on*)
(* white/black listing in .inferconfig and the default value *) (* white/black listing in .inferconfig and the default value *)
let is_checker_enabled = let is_checker_enabled checker_name =
let black_listed_checks = lazy ( match IList.mem (=) checker_name Config.disable_checks,
lookup_string_list "disable_checks" (Lazy.force Config.inferconfig_json)) in IList.mem (=) checker_name Config.enable_checks with
let white_listed_checks = lazy (
lookup_string_list "enable_checks" (Lazy.force Config.inferconfig_json)) in
(* return a closure so that we automatically memoize the json lookups thanks to lazy *)
function checker_name ->
match IList.mem (=) checker_name (Lazy.force black_listed_checks),
IList.mem (=) checker_name (Lazy.force white_listed_checks) with
| false, false -> (* if it's not amond white/black listed then we use default value *) | false, false -> (* if it's not amond white/black listed then we use default value *)
not (IList.mem (=) checker_name Config.checks_disabled_by_default) not (IList.mem (=) checker_name Config.checks_disabled_by_default)
| true, false -> (* if it's blacklisted and not whitelisted then it should be disabled *) | true, false -> (* if it's blacklisted and not whitelisted then it should be disabled *)

Loading…
Cancel
Save