From e7a27cc8ff5f41a18d14e069ec9e89e8ce0becca Mon Sep 17 00:00:00 2001 From: Manu Sridharan Date: Sat, 7 Oct 2023 17:03:35 -0700 Subject: [PATCH] cleanup --- .../NullAwayAutoSuggestNoCastTest.java | 39 +------------------ .../nullaway/NullAwayAutoSuggestTest.java | 21 +--------- 2 files changed, 3 insertions(+), 57 deletions(-) diff --git a/nullaway/src/test/java/com/uber/nullaway/NullAwayAutoSuggestNoCastTest.java b/nullaway/src/test/java/com/uber/nullaway/NullAwayAutoSuggestNoCastTest.java index 4ed879279f..1817d25f84 100644 --- a/nullaway/src/test/java/com/uber/nullaway/NullAwayAutoSuggestNoCastTest.java +++ b/nullaway/src/test/java/com/uber/nullaway/NullAwayAutoSuggestNoCastTest.java @@ -23,8 +23,6 @@ package com.uber.nullaway; import com.google.errorprone.BugCheckerRefactoringTestHelper; -import com.google.errorprone.ErrorProneFlags; -import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -36,54 +34,21 @@ public class NullAwayAutoSuggestNoCastTest { @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); - private ErrorProneFlags flagsWithAutoFixSuppressionComment; - - private ErrorProneFlags flagsNoAutoFixSuppressionComment; - - @Before - public void setup() { - // With AutoFixSuppressionComment - ErrorProneFlags.Builder b = ErrorProneFlags.builder(); - b.putFlag("NullAway:AnnotatedPackages", "com.uber,com.ubercab,io.reactivex"); - b.putFlag("NullAway:SuggestSuppressions", "true"); - b.putFlag("NullAway:AutoFixSuppressionComment", "PR #000000"); - flagsWithAutoFixSuppressionComment = b.build(); - // Without AutoFixSuppressionComment - b = ErrorProneFlags.builder(); - b.putFlag("NullAway:AnnotatedPackages", "com.uber,com.ubercab,io.reactivex"); - b.putFlag("NullAway:SuggestSuppressions", "true"); - flagsNoAutoFixSuppressionComment = b.build(); - } - - // In EP 2.6.0 the newInstance() method we use below is deprecated. We cannot currently address - // the warning since the replacement method was only added in EP 2.5.1, and we still want to - // support EP 2.4.0. So, we suppress the warning for now - @SuppressWarnings("deprecation") private BugCheckerRefactoringTestHelper makeTestHelperWithSuppressionComment() { - return BugCheckerRefactoringTestHelper.newInstance( - new NullAway(flagsWithAutoFixSuppressionComment), getClass()) + return BugCheckerRefactoringTestHelper.newInstance(NullAway.class, getClass()) .setArgs( "-d", temporaryFolder.getRoot().getAbsolutePath(), - // the remaining args are not needed right now, but they will be necessary when we - // switch to the more modern newInstance() API "-XepOpt:NullAway:AnnotatedPackages=com.uber,com.ubercab,io.reactivex", "-XepOpt:NullAway:SuggestSuppressions=true", "-XepOpt:NullAway:AutoFixSuppressionComment=PR #000000"); } - // In EP 2.6.0 the newInstance() method we use below is deprecated. We cannot currently address - // the warning since the replacement method was only added in EP 2.5.1, and we still want to - // support EP 2.4.0. So, we suppress the warning for now - @SuppressWarnings("deprecation") private BugCheckerRefactoringTestHelper makeTestHelper() { - return BugCheckerRefactoringTestHelper.newInstance( - new NullAway(flagsNoAutoFixSuppressionComment), getClass()) + return BugCheckerRefactoringTestHelper.newInstance(NullAway.class, getClass()) .setArgs( "-d", temporaryFolder.getRoot().getAbsolutePath(), - // the remaining args are not needed right now, but they will be necessary when we - // switch to the more modern newInstance() API "-XepOpt:NullAway:AnnotatedPackages=com.uber,com.ubercab,io.reactivex", "-XepOpt:NullAway:SuggestSuppressions=true"); } diff --git a/nullaway/src/test/java/com/uber/nullaway/NullAwayAutoSuggestTest.java b/nullaway/src/test/java/com/uber/nullaway/NullAwayAutoSuggestTest.java index 03ae7e35a3..ba5eabea27 100644 --- a/nullaway/src/test/java/com/uber/nullaway/NullAwayAutoSuggestTest.java +++ b/nullaway/src/test/java/com/uber/nullaway/NullAwayAutoSuggestTest.java @@ -25,11 +25,9 @@ import static com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH; import com.google.errorprone.BugCheckerRefactoringTestHelper; -import com.google.errorprone.ErrorProneFlags; import com.sun.source.tree.Tree; import com.uber.nullaway.testlibrarymodels.TestLibraryModels; import java.io.IOException; -import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -41,30 +39,13 @@ public class NullAwayAutoSuggestTest { @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); - private ErrorProneFlags flags; - - @Before - public void setup() { - ErrorProneFlags.Builder b = ErrorProneFlags.builder(); - b.putFlag("NullAway:AnnotatedPackages", "com.uber,com.ubercab,io.reactivex"); - b.putFlag("NullAway:CastToNonNullMethod", "com.uber.nullaway.testdata.Util.castToNonNull"); - b.putFlag("NullAway:SuggestSuppressions", "true"); - flags = b.build(); - } - - // In EP 2.6.0 the newInstance() method we use below is deprecated. We cannot currently address - // the warning since the replacement method was only added in EP 2.5.1, and we still want to - // support EP 2.4.0. So, we suppress the warning for now - @SuppressWarnings("deprecation") private BugCheckerRefactoringTestHelper makeTestHelper() { - return BugCheckerRefactoringTestHelper.newInstance(new NullAway(flags), getClass()) + return BugCheckerRefactoringTestHelper.newInstance(NullAway.class, getClass()) .setArgs( "-d", temporaryFolder.getRoot().getAbsolutePath(), "-processorpath", TestLibraryModels.class.getProtectionDomain().getCodeSource().getLocation().getPath(), - // the remaining args are not needed right now, but they will be necessary when we - // switch to the more modern newInstance() API "-XepOpt:NullAway:AnnotatedPackages=com.uber,com.ubercab,io.reactivex", "-XepOpt:NullAway:CastToNonNullMethod=com.uber.nullaway.testdata.Util.castToNonNull", "-XepOpt:NullAway:SuggestSuppressions=true");