From 130a729674a869eddcdb339aaf826fe5adcc1cad Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Tue, 5 Mar 2019 11:22:47 -0800 Subject: [PATCH] [infer] report the Fragment Retains View issues as warnings instead of errors Reviewed By: mbouaziz Differential Revision: D14313596 fbshipit-source-id: 13a6824de --- infer/src/checkers/fragmentRetainsViewChecker.ml | 7 ++++--- infer/tests/codetoanalyze/java/checkers/issues.exp | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/infer/src/checkers/fragmentRetainsViewChecker.ml b/infer/src/checkers/fragmentRetainsViewChecker.ml index ed5b3613b..5e95a0914 100644 --- a/infer/src/checkers/fragmentRetainsViewChecker.ml +++ b/infer/src/checkers/fragmentRetainsViewChecker.ml @@ -32,7 +32,7 @@ let format_method pname = Typ.Procname.to_string pname -let report_error fragment_typ fld fld_typ summary pdesc = +let report_warning fragment_typ fld fld_typ summary pdesc = let pname = Procdesc.get_proc_name pdesc in let description = Printf.sprintf @@ -42,7 +42,7 @@ let report_error fragment_typ fld fld_typ summary pdesc = (format_typ fragment_typ) (format_field fld) (format_typ fld_typ) (format_method pname) in let loc = Procdesc.get_loc pdesc in - Reporting.log_error summary ~loc IssueType.checkers_fragment_retain_view description + Reporting.log_warning summary ~loc IssueType.checkers_fragment_retain_view description let callback_fragment_retains_view_java pname_java {Callbacks.proc_desc; summary; tenv} = @@ -76,7 +76,8 @@ let callback_fragment_retains_view_java pname_java {Callbacks.proc_desc; summary not ( Annotations.ia_ends_with ia Annotations.auto_cleanup || Typ.Fieldname.Set.mem fname fields_nullified ) - then report_error (Typ.mk (Tstruct class_typename)) fname fld_typ summary proc_desc ) + then report_warning (Typ.mk (Tstruct class_typename)) fname fld_typ summary proc_desc + ) declared_view_fields | _ -> () diff --git a/infer/tests/codetoanalyze/java/checkers/issues.exp b/infer/tests/codetoanalyze/java/checkers/issues.exp index e5f6f2e97..ef69a7d1e 100644 --- a/infer/tests/codetoanalyze/java/checkers/issues.exp +++ b/infer/tests/codetoanalyze/java/checkers/issues.exp @@ -26,9 +26,9 @@ codetoanalyze/java/checkers/ExpensiveInheritanceExample.java, codetoanalyze.java codetoanalyze/java/checkers/ExpensiveInheritanceExample.java, codetoanalyze.java.checkers.ExpensiveInheritanceExample.reportsBecauseFooIsExpensiveInA(codetoanalyze.java.checkers.A):void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] codetoanalyze/java/checkers/ExpensiveInterfaceExample.java, codetoanalyze.java.checkers.ExpensiveInterfaceExample$ImplementsInterface.m1():void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] codetoanalyze/java/checkers/ExpensiveSubtypingExample.java, codetoanalyze.java.checkers.ExpensiveSubtypingExample.m3():void, 0, CHECKERS_EXPENSIVE_OVERRIDES_UNANNOTATED, no_bucket, ERROR, [] -codetoanalyze/java/checkers/FragmentRetainsViewExample.java, codetoanalyze.java.checkers.FragmentRetainsViewExample.onDestroyView():void, 0, CHECKERS_FRAGMENT_RETAINS_VIEW, no_bucket, ERROR, [] -codetoanalyze/java/checkers/FragmentRetainsViewExample.java, codetoanalyze.java.checkers.FragmentRetainsViewExample.onDestroyView():void, 0, CHECKERS_FRAGMENT_RETAINS_VIEW, no_bucket, ERROR, [] -codetoanalyze/java/checkers/FragmentRetainsViewExample.java, codetoanalyze.java.checkers.FragmentRetainsViewExample.onDestroyView():void, 0, CHECKERS_FRAGMENT_RETAINS_VIEW, no_bucket, ERROR, [] +codetoanalyze/java/checkers/FragmentRetainsViewExample.java, codetoanalyze.java.checkers.FragmentRetainsViewExample.onDestroyView():void, 0, CHECKERS_FRAGMENT_RETAINS_VIEW, no_bucket, WARNING, [] +codetoanalyze/java/checkers/FragmentRetainsViewExample.java, codetoanalyze.java.checkers.FragmentRetainsViewExample.onDestroyView():void, 0, CHECKERS_FRAGMENT_RETAINS_VIEW, no_bucket, WARNING, [] +codetoanalyze/java/checkers/FragmentRetainsViewExample.java, codetoanalyze.java.checkers.FragmentRetainsViewExample.onDestroyView():void, 0, CHECKERS_FRAGMENT_RETAINS_VIEW, no_bucket, WARNING, [] codetoanalyze/java/checkers/ImmutableCast.java, codetoanalyze.java.checkers.ImmutableCast.badCast(com.google.common.collect.ImmutableList):java.util.List, 0, CHECKERS_IMMUTABLE_CAST, no_bucket, WARNING, [Method badCast(...) returns class com.google.common.collect.ImmutableList but the return type is class java.util.List. Make sure that users of this method do not try to modify the collection.] codetoanalyze/java/checkers/ImmutableCast.java, codetoanalyze.java.checkers.ImmutableCast.badCastFromField():java.util.List, 0, CHECKERS_IMMUTABLE_CAST, no_bucket, WARNING, [Method badCastFromField() returns class com.google.common.collect.ImmutableList but the return type is class java.util.List. Make sure that users of this method do not try to modify the collection.] codetoanalyze/java/checkers/NoAllocationExample.java, codetoanalyze.java.checkers.NoAllocationExample.directlyAllocatingMethod():void, 1, CHECKERS_ALLOCATES_MEMORY, no_bucket, ERROR, []