[infer] Make infer respect external-packages param

Summary:
Fixes #1126

Different checks contain some ad hoc places that look at this param, but there is no systematic way to suppress this.
The centralized place that is filtering results is `reporting.ml`.

Note that this diff does not remove other usages, because they do more than mere filtering results.

Reviewed By: jvillard

Differential Revision: D16339655

fbshipit-source-id: afabdc97a
master
Mitya Lyubarskiy 6 years ago committed by Facebook Github Bot
parent 9be3af16ac
commit 7368039ba8

@ -36,12 +36,20 @@ let log_issue_from_summary severity summary ~node ~session ~loc ~ltr ?extras exn
| _ ->
false
in
let is_java_external_package =
match procname with
| Typ.Procname.Java java_pname ->
Typ.Procname.Java.is_external java_pname
| _ ->
false
in
let should_suppress_lint =
Language.curr_language_is Java
&& Annotations.ia_is_suppress_lint
(Summary.get_attributes summary).ProcAttributes.method_annotation.return
in
if should_suppress_lint || is_java_generated_method then () (* Skip the reporting *)
if should_suppress_lint || is_java_generated_method || is_java_external_package then ()
(* Skip the reporting *)
else
let err_log = Summary.get_err_log summary in
let clang_method_kind = Some attrs.clang_method_kind in

@ -188,7 +188,16 @@ let checker {Callbacks.summary; exe_env} =
let report_access_path ap udchain =
match AccessPath.get_field_and_annotation ap proc_data.tenv with
| Some (field_name, _) when is_outside_codebase proc_name field_name ->
(* Skip reporting when the field is outside the analyzed codebase *)
(* Skip reporting when the field is outside the analyzed codebase.
Note that we do similar filtering on high level which is common
for all checkers.
But this one is different: here we look NOT at the function
to be reported (the one that is using the field), but the root
cause (the field with the wrong annotation itself).
NOTE: Ideally we'd like to support such filtering in the way that
is agnostic to particular checker, but it is not trivial to
do, so let's do it in ad hoc way.
*)
()
| Some (field_name, _) when Typ.Fieldname.Java.is_captured_parameter field_name ->
(* Skip reporting when field comes from generated code *)

Loading…
Cancel
Save