[Infer][filtering] Always using local_config to build procedure filter

master
Sam Blackshear 10 years ago
parent ea7c13ff6c
commit e46b6d3c9d

@ -300,6 +300,17 @@ let load_filters analyzer =
with Sys_error _ -> None with Sys_error _ -> None
else None else None
(** parse autogenerated list of procedures/classes with Java @SuppressWarnings annotations. This
list is generated by an annotation parser than runs with the javac compilation step and saved in
the [local_config] file *)
let make_proc_filter_from_local_config () =
let filter = match !local_config with
| Some f ->
(try ProcMatcher.load_matcher f
with Yojson.Json_error _ -> ProcMatcher.default_matcher)
| None -> ProcMatcher.default_matcher in
fun pname -> not (filter DB.source_file_empty pname)
let filters_from_inferconfig inferconfig : filters = let filters_from_inferconfig inferconfig : filters =
let path_filter = let path_filter =
let whitelist_filter : path_filter = let whitelist_filter : path_filter =
@ -317,28 +328,23 @@ let filters_from_inferconfig inferconfig : filters =
function error_name -> function error_name ->
let error_str = Localise.to_string error_name in let error_str = Localise.to_string error_name in
not (list_exists (string_equal error_str) inferconfig.suppress_errors) in not (list_exists (string_equal error_str) inferconfig.suppress_errors) in
let proc_filter =
let filter = match !local_config with
| Some f -> ProcMatcher.load_matcher f
| None -> ProcMatcher.default_matcher in
fun pname -> not (filter DB.source_file_empty pname) in
{ {
path_filter = path_filter; path_filter = path_filter;
error_filter = error_filter; error_filter = error_filter;
proc_filter = proc_filter; proc_filter = default_proc_filter;
} }
(* Create filters based on .inferconfig.*) (* Create filters based on .inferconfig.*)
(* The environment varialble NO_PATH_FILTERING disables path filtering. *) (* The environment varialble NO_PATH_FILTERING disables path filtering. *)
let create_filters analyzer = let create_filters analyzer =
Config.project_root := Some (Sys.getcwd ()); Config.project_root := Some (Sys.getcwd ());
if Config.from_env_variable "NO_PATH_FILTERING" then if Config.from_env_variable "NO_PATH_FILTERING" then do_not_filter
do_not_filter
else else
let filters =
match load_filters (Utils.string_of_analyzer analyzer) with match load_filters (Utils.string_of_analyzer analyzer) with
| None -> do_not_filter | None -> do_not_filter
| Some inferconfig -> | Some inferconfig -> filters_from_inferconfig inferconfig in
filters_from_inferconfig inferconfig { filters with proc_filter = make_proc_filter_from_local_config () }
(* This function loads and list the path that are being filtered by the analyzer. The results *) (* This function loads and list the path that are being filtered by the analyzer. The results *)
(* are of the form: path/to/file.java -> {infer, eradicate} meaning that analysis results will *) (* are of the form: path/to/file.java -> {infer, eradicate} meaning that analysis results will *)

Loading…
Cancel
Save