From c2b512c227944bcbcfad870dddda0a50ebc64c6c Mon Sep 17 00:00:00 2001 From: Mitya Lyubarskiy Date: Wed, 15 Apr 2020 06:23:36 -0700 Subject: [PATCH] [nullsafe] Properly exclude third party methods from analysis Summary: Currently we exlude only if the method is based on deprecated config packages. Lets use the proper method, which covers both cases (config + user-defined third party repo). Reviewed By: artempyanykh Differential Revision: D20946506 fbshipit-source-id: c3332667f --- infer/src/nullsafe/eradicate.ml | 6 +++++- infer/tests/codetoanalyze/java/nullsafe-default/issues.exp | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/infer/src/nullsafe/eradicate.ml b/infer/src/nullsafe/eradicate.ml index e5107898e..4315cea50 100644 --- a/infer/src/nullsafe/eradicate.ml +++ b/infer/src/nullsafe/eradicate.ml @@ -180,7 +180,11 @@ let find_reason_to_skip_analysis proc_name proc_desc = match proc_name with | Procname.Java java_pname -> if Procname.Java.is_access_method java_pname then Some "access method" - else if Procname.Java.is_external java_pname then Some "third party method" + else if + ThirdPartyAnnotationInfo.is_third_party_proc + (ThirdPartyAnnotationGlobalRepo.get_repo ()) + proc_name + then Some "third party method" else if (Procdesc.get_attributes proc_desc).ProcAttributes.is_bridge_method then Some "bridge method" else None diff --git a/infer/tests/codetoanalyze/java/nullsafe-default/issues.exp b/infer/tests/codetoanalyze/java/nullsafe-default/issues.exp index 940eaaead..a58225d5f 100644 --- a/infer/tests/codetoanalyze/java/nullsafe-default/issues.exp +++ b/infer/tests/codetoanalyze/java/nullsafe-default/issues.exp @@ -407,4 +407,3 @@ codetoanalyze/java/nullsafe-default/TrueFalseOnNull.java, codetoanalyze.java.nul codetoanalyze/java/nullsafe-default/TrueFalseOnNull.java, codetoanalyze.java.nullsafe_default.TrueFalseOnNull$TestStaticOneParam.trueOnNullPositiveBranchIsBAD(java.lang.String):void, 2, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [`s` is nullable and is not locally checked for null when calling `toString()`.] codetoanalyze/java/nullsafe-default/TryWithResource.java, Linters_dummy_method, 1, ERADICATE_META_CLASS_NEEDS_IMPROVEMENT, no_bucket, INFO, [], TryWithResource, codetoanalyze.java.nullsafe_default, issues: 1, curr_mode: "Default" codetoanalyze/java/nullsafe-default/TryWithResource.java, codetoanalyze.java.nullsafe_default.TryWithResource.FP_OK_StringWriterInTWRBlock():void, 8, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [NullPointerException will be thrown at this line! Object is `null` and is dereferenced via calling `addSuppressed(...)`: null constant at line 22.] -codetoanalyze/java/nullsafe-default/third-party-test-code/some/test/pckg/ThirdPartyTestClass.java, some.test.pckg.ThirdPartyTestClass.returnSpecifiedAsNullable():java.lang.String, 0, ERADICATE_RETURN_OVER_ANNOTATED, no_bucket, ADVICE, [Method `returnSpecifiedAsNullable()` is annotated with `@Nullable` but never returns null.]