Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar committed Oct 8, 2023
1 parent ce971d5 commit e7a27cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Expand Down

0 comments on commit e7a27cc

Please sign in to comment.