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

master
Sam Blackshear 10 years ago
parent ea7c13ff6c
commit e46b6d3c9d

@ -286,19 +286,30 @@ let inferconfig () = match !inferconfig_home with
let load_filters analyzer = let load_filters analyzer =
let inferconfig_file = inferconfig () in let inferconfig_file = inferconfig () in
if Sys.file_exists inferconfig_file then if Sys.file_exists inferconfig_file then
try try
let json = Yojson.Basic.from_file inferconfig_file in let json = Yojson.Basic.from_file inferconfig_file in
let inferconfig = let inferconfig =
{ {
whitelist = lookup_string_list (analyzer ^ "_whitelist") json; whitelist = lookup_string_list (analyzer ^ "_whitelist") json;
blacklist = lookup_string_list (analyzer ^ "_blacklist") json; blacklist = lookup_string_list (analyzer ^ "_blacklist") json;
blacklist_files_containing = blacklist_files_containing =
lookup_string_list (analyzer ^ "_blacklist_files_containing") json; lookup_string_list (analyzer ^ "_blacklist_files_containing") json;
suppress_errors = lookup_string_list (analyzer ^ "_suppress_errors") json; suppress_errors = lookup_string_list (analyzer ^ "_suppress_errors") json;
} in } in
Some inferconfig Some inferconfig
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 =
@ -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
match load_filters (Utils.string_of_analyzer analyzer) with let filters =
| None -> do_not_filter match load_filters (Utils.string_of_analyzer analyzer) with
| Some inferconfig -> | None -> do_not_filter
filters_from_inferconfig inferconfig | Some inferconfig -> filters_from_inferconfig inferconfig in
{ 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