[cli] warn about deprecated options, clean up infer repo

Summary:
Also make sure we don't introduce deprecated options in our repo, eg when
calling infer from infer.

Reviewed By: jeremydubreil

Differential Revision: D4430379

fbshipit-source-id: 77ea7fd
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent cb1e241411
commit ca784cdb41

@ -1,5 +1,5 @@
{
"skip_translation": [
"skip-translation": [
{
"language": "Java",
"source_contains": "_SHOULD_BE_SKIPPED_"

@ -7,6 +7,10 @@
SHELL = bash
# Make infer crash a bit more often to detect issues in the way we call infer within this repo, eg,
# using deprecated options.
export INFER_STRICT_MODE=1
include $(ROOT_DIR)/Makefile.autoconf
PLATFORM = $(shell uname)

@ -62,7 +62,7 @@ def prepare_build(args):
infer_cache_dir = os.path.join(args.infer_out, 'cache')
if not os.path.isdir(infer_cache_dir):
os.mkdir(infer_cache_dir)
infer_options += ['--infer_cache', infer_cache_dir]
infer_options += ['--infer-cache', infer_cache_dir]
temp_files = [infer_cache_dir]
try:

@ -111,7 +111,7 @@ def dump_json_to_path(
def infer_version():
version = json.loads(subprocess.check_output([
get_cmd_in_bin_dir('InferAnalyze'),
'-version_json',
'--version-json',
]).decode())
return version['commit']
@ -119,7 +119,7 @@ def infer_version():
def infer_branch():
version = json.loads(subprocess.check_output([
get_cmd_in_bin_dir('InferAnalyze'),
'-version_json',
'--version-json',
]).decode())
return version['branch']

@ -41,7 +41,7 @@ let pp_cluster fmt (nr, cluster) =
let pp_cl fmt n = Format.fprintf fmt "%s" (cl_name n) in
store_to_file (DB.filename_from_string fname) (nr, cluster);
F.fprintf fmt "%a: @\n" pp_cl nr;
F.fprintf fmt "\t$(INFERANALYZE) -cluster '%s'@\n" fname;
F.fprintf fmt "\t$(INFERANALYZE) --cluster '%s'@\n" fname;
(* touch the target of the rule to let `make` know that the job has been done *)
F.fprintf fmt "\t@@touch $@@@\n";
F.fprintf fmt "@\n"

@ -42,7 +42,7 @@ let pp_prolog fmt clusters =
let compilation_dbs_cmd =
IList.map (F.sprintf "--clang-compilation-db-files '%s'") !Config.clang_compilation_db_files
|> String.concat ~sep:" " |> escape in
F.fprintf fmt "INFERANALYZE= %s -results_dir '%s' %s \n@."
F.fprintf fmt "INFERANALYZE= %s --results-dir '%s' %s \n@."
(Config.bin_dir ^/ (CLOpt.exe_name Analyze))
(escape Config.results_dir)
compilation_dbs_cmd;

@ -280,7 +280,7 @@ let patterns_of_json_with_key (json_key, json) =
error in
let warn_user msg =
F.eprintf "WARNING: in file %s: error parsing option %s@\n%s"
F.eprintf "WARNING: in file %s: error parsing option %s@\n%s@."
Config.inferconfig_file json_key msg in
(* Translate all the JSON entries into matching patterns *)

@ -29,6 +29,11 @@ let to_arg_spec = function
| Symbol (symbols, f) -> Arg.Symbol (symbols, f)
| Rest f -> Arg.Rest f
let is_env_var_set v =
Option.value (Option.map (Sys.getenv v) ~f:((=) "1")) ~default:false
let warnf = if is_env_var_set "INFER_STRICT_MODE" then failwithf else F.eprintf
(** Each command line option may appear in the --help list of any executable, these tags are used to
specify which executables for which an option will be documented. *)
type exe = Analyze | Clang | Driver | Interactive | Print
@ -210,6 +215,22 @@ let add exes desc =
desc_list := desc :: !desc_list
) exe_desc_lists
let deprecate_desc ~long ~short ~deprecated desc =
let warn () =
warnf "WARNING: '-%s' is deprecated. Use '--%s'%s instead.@."
deprecated long (if short = "" then "" else Printf.sprintf " or '-%s'" short) in
let warn_then_f f x = warn (); f x in
let deprecated_spec = match desc.spec with
| Unit f -> Unit (warn_then_f f)
| String f -> String (warn_then_f f)
| Symbol (symbols, f) -> Symbol (symbols, warn_then_f f)
| Rest _ as spec -> spec in
let deprecated_decode_json j =
F.eprintf "WARNING: in .inferconfig: '%s' is deprecated. Use '%s' instead.@." deprecated long;
desc.decode_json j in
{ long = ""; short = deprecated; meta = ""; doc = "";
spec = deprecated_spec; decode_json = deprecated_decode_json }
let mk ?(deprecated=[]) ?(exes=[])
~long ?(short="") ~default ~meta doc ~default_to_string ~decode_json ~mk_setter ~mk_spec =
let variable = ref default in
@ -231,9 +252,9 @@ let mk ?(deprecated=[]) ?(exes=[])
if short <> "" then
add [] {desc with long = ""; meta = ""; doc = ""} ;
(* add desc for deprecated options only for parsing, without documentation *)
IList.iter (fun deprecated ->
add [] {desc with long = ""; short = deprecated; meta = ""; doc = ""}
) deprecated ;
List.iter deprecated ~f:(fun deprecated ->
deprecate_desc ~long ~short ~deprecated desc
|> add []) ;
variable
(* arguments passed to Arg.parse_argv_dynamic, susceptible to be modified on the fly when parsing *)

@ -1,5 +1,5 @@
all:
InferAnalyze -results_dir out -checkers
InferAnalyze --results-dir out -checkers
.PHONY: capture
capture:

@ -1,5 +1,5 @@
{
"skip_translation": [
"skip-translation": [
{
"language": "Java",
"source_contains": "_SHOULD_BE_SKIPPED_"

@ -10,7 +10,7 @@ SYM_ROOT = ../codetoanalyze/linters/tsrc_symlink
TESTS_DIR = ../..
ANALYZER = linters
CLANG_OPTIONS = -x objective-c++ -std=c++11 -fblocks -c
INFER_OPTIONS = --no-filtering --debug-exceptions --project_root $(SYM_ROOT)
INFER_OPTIONS = --no-filtering --debug-exceptions --project-root $(SYM_ROOT)
INFERPRINT_OPTIONS = --issues-tests
SOURCES = $(SYM_ROOT)/main.mm

@ -1,5 +1,5 @@
{
"never_returning_null": [
"never-returning-null": [
{
"language": "Java",
"source_contains": "_AUTOMATICALLY_GENERATED_"
@ -13,16 +13,16 @@
"infer-blacklist-files-containing": [
"@generated"
],
"enable_checks": [
"enable-checks": [
"GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL"
],
"skip_translation": [
"skip-translation": [
{
"language": "Java",
"source_contains": "_SHOULD_BE_SKIPPED_"
}
],
"modeled_expensive": [
"modeled-expensive": [
{
"language": "Java",
"class": "android.app.Activity",

@ -1,5 +1,5 @@
{
"modeled_expensive": [
"modeled-expensive": [
{
"language": "Java",
"class": "android.app.Activity",

@ -1,5 +1,5 @@
{
"never_returning_null": [
"never-returning-null": [
{
"language": "Java",
"source_contains": "_AUTOMATICALLY_GENERATED_"
@ -13,7 +13,7 @@
"infer-blacklist-files-containing": [
"@generated"
],
"skip_translation": [
"skip-translation": [
{
"language": "Java",
"source_contains": "_SHOULD_BE_SKIPPED_"

@ -1,5 +1,5 @@
{
"never_returning_null": [
"never-returning-null": [
{
"language": "Java",
"source_contains": "_AUTOMATICALLY_GENERATED_"
@ -13,7 +13,7 @@
"infer-blacklist-files-containing": [
"@generated"
],
"skip_translation": [
"skip-translation": [
{
"language": "Java",
"source_contains": "_SHOULD_BE_SKIPPED_"

Loading…
Cancel
Save