From 9748a8f1a3623beedc720d4129aa5fa5fed74168 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Fri, 20 May 2016 09:49:20 -0700 Subject: [PATCH] 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 --- infer/src/backend/config.ml | 10 ++++++++++ infer/src/backend/config.mli | 2 ++ infer/src/backend/inferconfig.ml | 20 +++----------------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/infer/src/backend/config.ml b/infer/src/backend/config.ml index 6e7024f18..e8d946467 100644 --- a/infer/src/backend/config.ml +++ b/infer/src/backend/config.ml @@ -427,11 +427,19 @@ and developer_mode = ~default:(CLOpt.current_exe = CLOpt.P) "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 *) and dotty_cfg_libs = CLOpt.mk_bool ~deprecated:["dotty_no_cfg_libs"] ~long:"dotty-cfg-libs" ~default:true "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. *) and eradicate, checkers = (** 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 dependency_mode = !dependencies and developer_mode = !developer_mode +and disable_checks = !disable_checks and dotty_cfg_libs = !dotty_cfg_libs +and enable_checks = !enable_checks and eradicate = !eradicate and err_file_cmdline = !err_file and infer_cache = !infer_cache diff --git a/infer/src/backend/config.mli b/infer/src/backend/config.mli index ba1ae8fbd..bdf54638a 100644 --- a/infer/src/backend/config.mli +++ b/infer/src/backend/config.mli @@ -126,7 +126,9 @@ val cxx_experimental : bool val debug_mode : bool val dependency_mode : bool val developer_mode : bool +val disable_checks : string list val dotty_cfg_libs : bool +val enable_checks : string list val eradicate : bool val err_file_cmdline : string val infer_cache : string option diff --git a/infer/src/backend/inferconfig.ml b/infer/src/backend/inferconfig.ml index 1f01c6391..5c40bbd13 100644 --- a/infer/src/backend/inferconfig.ml +++ b/infer/src/backend/inferconfig.ml @@ -11,14 +11,6 @@ open! Utils 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 error_filter = Localise.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*) (* white/black listing in .inferconfig and the default value *) -let is_checker_enabled = - let black_listed_checks = lazy ( - lookup_string_list "disable_checks" (Lazy.force Config.inferconfig_json)) in - 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 +let is_checker_enabled checker_name = + match IList.mem (=) checker_name Config.disable_checks, + IList.mem (=) checker_name Config.enable_checks with | 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) | true, false -> (* if it's blacklisted and not whitelisted then it should be disabled *)