[infer] Add the possibility to skip the analysis of some files based on their path

Summary:
Just adds a language agnostic option to skip the analysis of some files based on the path name. Can be used from the command line with:

  infer infer --skip-analysis-in-path "some/path/" ...

or via the `.inferconfig` file:

  {
    "skip-analysis-in-path": [
      "infer/demo/Resource.java"
    ]
  }

Reviewed By: jberdine

Differential Revision: D3954809

fbshipit-source-id: d0d2b9f
master
Jeremy Dubreil 8 years ago committed by Facebook Github Bot
parent 777378e7cc
commit ea72dadab3

@ -916,7 +916,7 @@ and (
mk_option ~deprecated:["never_returning_null"] ~long:"never-returning-null"
"Matcher or list of matchers for functions that never return `null`.",
mk_option ~deprecated:["skip_translation"] ~long:"skip-translation"
"Matcher or list of matchers for names of files that should be analyzed at all.")
"Matcher or list of matchers for names of files that should not be analyzed at all.")
and pmd_xml =
CLOpt.mk_bool ~long:"pmd-xml"
@ -988,6 +988,11 @@ and skip_clang_analysis_in_path =
~exes:CLOpt.[Clang]
~meta:"path prefix" "Ignore files whose path matches the given prefix"
and skip_analysis_in_path =
CLOpt.mk_string_list ~long:"skip-analysis-in-path"
~exes:CLOpt.[Clang;Java]
~meta:"path prefix" "Ignore files whose path matches the given prefix"
and skip_translation_headers =
CLOpt.mk_string_list ~deprecated:["skip_translation_headers"] ~long:"skip-translation-headers"
~exes:CLOpt.[Clang]
@ -1464,6 +1469,7 @@ and save_analysis_results = !save_results
and seconds_per_iteration = !seconds_per_iteration
and show_buckets = !print_buckets
and show_progress_bar = !progress_bar
and skip_analysis_in_path = !skip_analysis_in_path
and skip_clang_analysis_in_path = !skip_clang_analysis_in_path
and skip_translation_headers = !skip_translation_headers
and source_file = !source_file

@ -238,6 +238,7 @@ val save_analysis_results : string option
val seconds_per_iteration : float
val show_buckets : bool
val show_progress_bar : bool
val skip_analysis_in_path : string list
val skip_clang_analysis_in_path : string list
val skip_translation_headers : string list
val source_file : string option

@ -126,7 +126,13 @@ let do_all_files classpath sources classes =
let program = JClasspath.load_program classpath classes in
let tenv = load_tenv () in
let linereader = Printer.LineReader.create () in
let skip source_file = Inferconfig.skip_translation_matcher source_file Procname.empty_block in
let skip source_file =
let is_path_matching path =
IList.exists
(fun pattern -> Str.string_match (Str.regexp pattern) path 0)
Config.skip_analysis_in_path in
is_path_matching (DB.source_file_to_rel_path source_file)
|| Inferconfig.skip_translation_matcher source_file Procname.empty_block in
let translate_source_file basename (package_opt, _) source_file =
init_global_state source_file;
if not (skip source_file) then

Loading…
Cancel
Save