cleanup inferconfig stuff now that everything has been ported to the CLI

Summary:
End of the migration of .inferconfig-specific options into options accepted
both by .inferconfig and the CLI.

Reviewed By: jberdine

Differential Revision: D3304798

fbshipit-source-id: 14f6833
master
Jules Villard 9 years ago committed by Facebook Github Bot 8
parent 21367b0e98
commit dbb6d08254

@ -313,17 +313,9 @@ let mk_anon () =
anon anon
(* begin temporarily export inferconfig_json while .inferconfig-specific options still exist *)
let inferconfig_json = ref (`Assoc [])
(* end temporarily export inferconfig_json *)
let decode_inferconfig_to_argv path = let decode_inferconfig_to_argv path =
let json = match read_optional_json_file path with let json = match read_optional_json_file path with
| Ok json -> | Ok json ->
(* begin temporarily export inferconfig_json while
.inferconfig-specific options still exist *)
inferconfig_json := json ;
(* end temporarily export inferconfig_json *)
json json
| Error msg -> | Error msg ->
F.eprintf "WARNING: Could not read or parse Infer config in %s:@\n%s@." path msg ; F.eprintf "WARNING: Could not read or parse Infer config in %s:@\n%s@." path msg ;
@ -340,8 +332,7 @@ let decode_inferconfig_to_argv path =
decode_json json_val @ result decode_json json_val @ result
with with
| Not_found -> | Not_found ->
(* TODO: have all json options be regular options as well. When this is done, we can show a F.eprintf "WARNING: while reading config file %s:@\nUnknown option %s@." path key ;
warning if a json key is not a valid option. *)
result result
| YBU.Type_error (msg, json) -> | YBU.Type_error (msg, json) ->
F.eprintf "WARNING: while reading config file %s:@\nIll-formed value %s for option %s: %s@." F.eprintf "WARNING: while reading config file %s:@\nIll-formed value %s for option %s: %s@."

@ -11,10 +11,6 @@
open! Utils open! Utils
(* begin temporarily export inferconfig_json while .inferconfig-specific options still exist *)
val inferconfig_json : Yojson.Basic.json ref
(* end temporarily export inferconfig_json *)
type exe = A | C | J | L | P | T type exe = A | C | J | L | P | T
val current_exe : exe val current_exe : exe

@ -217,26 +217,25 @@ let patterns_of_json_with_key json_key json =
let default_source_contains = "" in let default_source_contains = "" in
let language_of_string json_key = function let language_of_string = function
| "Java" -> | "Java" ->
Ok Java Ok Java
| l -> | l ->
Error ("Inferconfig JSON key " ^ json_key ^ " not supported for language " ^ l) in Error ("Inferconfig JSON key " ^ json_key ^ " not supported for language " ^ l) in
let detect_language json_key assoc = let rec detect_language = function
let rec loop = function | [] ->
| [] -> Error ("No language found for " ^ json_key ^ " in " ^ inferconfig_file)
Error ("No language found for " ^ json_key ^ " in " ^ inferconfig_file) | ("language", `String s) :: _ ->
| ("language", `String s) :: _ -> language_of_string s
language_of_string json_key s | _:: tl ->
| _:: tl -> loop tl in detect_language tl in
loop assoc in
(* Detect the kind of pattern, method pattern or pattern based on the content of the source file. (* Detect the kind of pattern, method pattern or pattern based on the content of the source file.
Detecting the kind of patterns in a first step makes it easier to parse the parts of the Detecting the kind of patterns in a first step makes it easier to parse the parts of the
pattern in a second step *) pattern in a second step *)
let detect_pattern json_key assoc = let detect_pattern assoc =
match detect_language json_key assoc with match detect_language assoc with
| Ok language -> | Ok language ->
let is_method_pattern key = IList.exists (string_equal key) ["class"; "method"] let is_method_pattern key = IList.exists (string_equal key) ["class"; "method"]
and is_source_contains key = IList.exists (string_equal key) ["source_contains"] in and is_source_contains key = IList.exists (string_equal key) ["source_contains"] in
@ -253,7 +252,7 @@ let patterns_of_json_with_key json_key json =
error in error in
(* Translate a JSON entry into a matching pattern *) (* Translate a JSON entry into a matching pattern *)
let create_pattern json_key (assoc : (string * Yojson.Basic.json) list) = let create_pattern (assoc : (string * Yojson.Basic.json) list) =
let collect_params l = let collect_params l =
let collect accu = function let collect accu = function
| `String s -> s:: accu | `String s -> s:: accu
@ -276,7 +275,7 @@ let patterns_of_json_with_key json_key json =
| (key, _) when key = "language" -> sc | (key, _) when key = "language" -> sc
| _ -> failwith ("Fails to parse " ^ Yojson.Basic.to_string (`Assoc assoc)) in | _ -> failwith ("Fails to parse " ^ Yojson.Basic.to_string (`Assoc assoc)) in
IList.fold_left loop default_source_contains assoc in IList.fold_left loop default_source_contains assoc in
match detect_pattern json_key assoc with match detect_pattern assoc with
| Ok (Method_pattern (language, _)) -> | Ok (Method_pattern (language, _)) ->
Ok (Method_pattern (language, create_method_pattern assoc)) Ok (Method_pattern (language, create_method_pattern assoc))
| Ok (Source_contains (language, _)) -> | Ok (Source_contains (language, _)) ->
@ -284,27 +283,26 @@ let patterns_of_json_with_key json_key json =
| Error _ as error -> | Error _ as error ->
error in error in
let warn_user key msg = let warn_user msg =
F.eprintf "WARNING: in file %s: error parsing option %s@\n%s" inferconfig_file json_key msg in F.eprintf "WARNING: in file %s: error parsing option %s@\n%s" inferconfig_file json_key msg in
(* Translate all the JSON entries into matching patterns *) (* Translate all the JSON entries into matching patterns *)
let rec translate json_key accu = function let rec translate accu = function
| `Assoc l -> ( | `Assoc l -> (
match create_pattern json_key l with match create_pattern l with
| Ok pattern -> | Ok pattern ->
pattern :: accu pattern :: accu
| Error msg -> | Error msg ->
warn_user json_key msg; warn_user msg;
accu) accu)
| `List l -> | `List l ->
IList.fold_left (translate json_key) accu l IList.fold_left translate accu l
| json -> | json ->
warn_user json_key warn_user (Printf.sprintf "expected list or assoc json type, but got value %s"
(Printf.sprintf "expected list or assoc json type, but got value %s" (Yojson.Basic.to_string json));
(Yojson.Basic.to_string json));
accu in accu in
translate json_key [] json translate [] json
(** Command Line options *) (** Command Line options *)
@ -1256,30 +1254,23 @@ and analysis_blacklist_files_containing analyzer =
and analysis_suppress_errors analyzer = and analysis_suppress_errors analyzer =
IList.assoc (=) analyzer analysis_suppress_errors_options IList.assoc (=) analyzer analysis_suppress_errors_options
let inferconfig_json = lazy !CLOpt.inferconfig_json let patterns_suppress_warnings =
and suppress_warnings_json = lazy (
let error msg = let error msg =
F.eprintf "There was an issue reading the option %s.@\n" F.eprintf "There was an issue reading the option %s.@\n"
suppress_warnings_annotations_long ; suppress_warnings_annotations_long ;
F.eprintf "If you did not call %s directly, this is likely a bug in Infer.@\n" F.eprintf "If you did not call %s directly, this is likely a bug in Infer.@\n"
(Filename.basename Sys.executable_name) ; (Filename.basename Sys.executable_name) ;
F.eprintf "%s@." msg ; F.eprintf "%s@." msg ;
exit 1 in [] in
match !suppress_warnings_out with match !suppress_warnings_out with
| Some path -> ( | Some path -> (
match read_optional_json_file path with match read_optional_json_file path with
| Ok json -> json | Ok json -> (
let json_key = "suppress_warnings" in
match Yojson.Basic.Util.member json_key json with
| `Null -> []
| json -> patterns_of_json_with_key json_key json)
| Error msg -> error ("Could not read or parse the supplied " ^ path ^ ":\n" ^ msg)) | Error msg -> error ("Could not read or parse the supplied " ^ path ^ ":\n" ^ msg))
| None -> | None ->
if CLOpt.(current_exe <> J) then `Null if CLOpt.(current_exe <> J) then []
else error ("Error: The option " ^ suppress_warnings_annotations_long ^ " was not provided")) else error ("Error: The option " ^ suppress_warnings_annotations_long ^ " was not provided")
let patterns_suppress_warnings =
let json_key = "suppress_warnings" in
match Lazy.force suppress_warnings_json with
| `Null -> []
| json ->
match Yojson.Basic.Util.member json_key json with
| `Null -> []
| json -> patterns_of_json_with_key json_key json

@ -58,7 +58,6 @@ val frontend_stats_dir_name : string
val global_tenv_filename : string val global_tenv_filename : string
val idempotent_getters : bool val idempotent_getters : bool
val incremental_procs : bool val incremental_procs : bool
val inferconfig_file : string
val initial_analysis_time : float val initial_analysis_time : float
val ivar_attributes : string val ivar_attributes : string
val log_analysis_file : string val log_analysis_file : string
@ -146,7 +145,6 @@ 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
val inferconfig_json : Yojson.Basic.json Lazy.t
val iterations : int val iterations : int
val javac_verbose_out : string val javac_verbose_out : string
val join_cond : int val join_cond : int
@ -193,7 +191,6 @@ val spec_abs_level : int
val specs_library : string list val specs_library : string list
val stats_mode : bool val stats_mode : bool
val subtype_multirange : bool val subtype_multirange : bool
val suppress_warnings_json : Yojson.Basic.json Lazy.t
val svg : bool val svg : bool
val symops_per_iteration : int val symops_per_iteration : int
val test : bool val test : bool

Loading…
Cancel
Save