diff --git a/infer/src/backend/inferconfig.ml b/infer/src/backend/inferconfig.ml index 8b9a9e86b..b579585e8 100644 --- a/infer/src/backend/inferconfig.ml +++ b/infer/src/backend/inferconfig.ml @@ -286,19 +286,30 @@ let inferconfig () = match !inferconfig_home with let load_filters analyzer = let inferconfig_file = inferconfig () in if Sys.file_exists inferconfig_file then - try - let json = Yojson.Basic.from_file inferconfig_file 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 - with Sys_error _ -> None - else None + try + let json = Yojson.Basic.from_file inferconfig_file 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 + with Sys_error _ -> 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 path_filter = @@ -317,28 +328,23 @@ let filters_from_inferconfig inferconfig : filters = function error_name -> let error_str = Localise.to_string error_name 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; error_filter = error_filter; - proc_filter = proc_filter; + proc_filter = default_proc_filter; } (* Create filters based on .inferconfig.*) (* The environment varialble NO_PATH_FILTERING disables path filtering. *) let create_filters analyzer = Config.project_root := Some (Sys.getcwd ()); - if Config.from_env_variable "NO_PATH_FILTERING" then - do_not_filter + 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 + let filters = + match load_filters (Utils.string_of_analyzer analyzer) with + | None -> do_not_filter + | 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 *) (* are of the form: path/to/file.java -> {infer, eradicate} meaning that analysis results will *)