From b419541af28727279f286cabbb8b607d6dad3067 Mon Sep 17 00:00:00 2001 From: Mitya Lyubarskiy Date: Fri, 1 May 2020 02:53:10 -0700 Subject: [PATCH] [nullsafe] Skip analysis of autogen methods Summary: We have a common entry point where we skip analysis in nullsafe. This logic is copied from `Reporting.log_issue_from_summary`. I believe this should not exist in Reporting: it is not the right place to decide whether to suppress issues: we should not try to report it in first place. Because of that we falsely report "needs improvement" meta-issue while we don't issue any (they were suppressed but participated in needs improvement count calculations). Now this change will make meta-issue to be synced with what the user actually sees. Down the line we should have a more reliable fix for that. So far I reviewed suppressing code and looks like we should not suppress anything else (unless explicitly SuppressLint-ed, which is fine). Reviewed By: artempyanykh Differential Revision: D21328634 fbshipit-source-id: 120ce06d1 --- infer/src/nullsafe/eradicate.ml | 1 + infer/tests/codetoanalyze/java/nullsafe/issues.exp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/infer/src/nullsafe/eradicate.ml b/infer/src/nullsafe/eradicate.ml index 8d040e3c3..f1e3a5939 100644 --- a/infer/src/nullsafe/eradicate.ml +++ b/infer/src/nullsafe/eradicate.ml @@ -187,6 +187,7 @@ let find_reason_to_skip_analysis proc_name proc_desc = then Some "third party method" else if (Procdesc.get_attributes proc_desc).ProcAttributes.is_bridge_method then Some "bridge method" + else if Procname.Java.is_autogen_method java_pname then Some "autogenerated method" else None | _ -> Some "not a Java method" diff --git a/infer/tests/codetoanalyze/java/nullsafe/issues.exp b/infer/tests/codetoanalyze/java/nullsafe/issues.exp index dd9902bbb..9f5e630b6 100644 --- a/infer/tests/codetoanalyze/java/nullsafe/issues.exp +++ b/infer/tests/codetoanalyze/java/nullsafe/issues.exp @@ -366,7 +366,7 @@ codetoanalyze/java/nullsafe/PropagatesNullable.java, codetoanalyze.java.nullsafe codetoanalyze/java/nullsafe/PropagatesNullable.java, codetoanalyze.java.nullsafe_default.TestPropagatesNullable$TestSecondParameter.test(java.lang.String,java.lang.String):void, 7, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [`nullable(...)` is nullable and is not locally checked for null when calling `length()`.] codetoanalyze/java/nullsafe/PropagatesNullable.java, codetoanalyze.java.nullsafe_default.TestPropagatesNullable$TestSecondParameter.test(java.lang.String,java.lang.String):void, 11, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [`nullable(...)` is nullable and is not locally checked for null when calling `length()`.] codetoanalyze/java/nullsafe/PropagatesNullable.java, codetoanalyze.java.nullsafe_default.TestPropagatesNullable$TestSecondParameter.test(java.lang.String,java.lang.String):void, 15, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [`nullable(...)` is nullable and is not locally checked for null when calling `length()`.] -codetoanalyze/java/nullsafe/ReturnNotNullable.java, Linters_dummy_method, 19, ERADICATE_META_CLASS_NEEDS_IMPROVEMENT, no_bucket, INFO, [], ReturnNotNullable, codetoanalyze.java.nullsafe_default, issues: 9, curr_mode: "Default" +codetoanalyze/java/nullsafe/ReturnNotNullable.java, Linters_dummy_method, 19, ERADICATE_META_CLASS_NEEDS_IMPROVEMENT, no_bucket, INFO, [], ReturnNotNullable, codetoanalyze.java.nullsafe_default, issues: 8, curr_mode: "Default" codetoanalyze/java/nullsafe/ReturnNotNullable.java, Linters_dummy_method, 154, ERADICATE_META_CLASS_CAN_BE_NULLSAFE, no_bucket, INFO, [], ReturnNotNullable$E, codetoanalyze.java.nullsafe_default, issues: 0, curr_mode: "Default", promote_mode: "Strict" codetoanalyze/java/nullsafe/ReturnNotNullable.java, Linters_dummy_method, 191, ERADICATE_META_CLASS_NEEDS_IMPROVEMENT, no_bucket, INFO, [], ReturnNotNullable$ConditionalAssignment, codetoanalyze.java.nullsafe_default, issues: 1, curr_mode: "Default" codetoanalyze/java/nullsafe/ReturnNotNullable.java, codetoanalyze.java.nullsafe_default.ReturnNotNullable$ConditionalAssignment.test(boolean):java.lang.Object, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [`test(...)`: return type is declared non-nullable but the method returns a nullable value: field f1 at line 199.]