Skip to content

Commit

Permalink
Introduce rule to drop default setFixChooser
Browse files Browse the repository at this point in the history
  • Loading branch information
Bastien Diederichs committed Mar 10, 2023
1 parent c3cd535 commit a4096e9
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 1 deletion.
1 change: 0 additions & 1 deletion error-prone-contrib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
<dependency>
<groupId>${groupId.error-prone}</groupId>
<artifactId>error_prone_test_helpers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package tech.picnic.errorprone.refasterrules;

import com.google.errorprone.BugCheckerRefactoringTestHelper;
import com.google.errorprone.BugCheckerRefactoringTestHelper.FixChoosers;
import com.google.errorprone.refaster.annotation.AfterTemplate;
import com.google.errorprone.refaster.annotation.BeforeTemplate;
import tech.picnic.errorprone.refaster.annotation.OnlineDocumentation;

@OnlineDocumentation
final class BugCheckerRules {
private BugCheckerRules() {}

/**
* Drop {@link
* BugCheckerRefactoringTestHelper#setFixChooser(BugCheckerRefactoringTestHelper.FixChooser)} when
* set to the default {@link FixChoosers#FIRST}.
*/
static final class SetFixChooserDefault {
@BeforeTemplate
BugCheckerRefactoringTestHelper before(BugCheckerRefactoringTestHelper helper) {
return helper.setFixChooser(FixChoosers.FIRST);
}

@AfterTemplate
BugCheckerRefactoringTestHelper after(BugCheckerRefactoringTestHelper helper) {
return helper;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ final class RefasterRulesTest {
AssertJThrowingCallableRules.class,
AssortedRules.class,
BigDecimalRules.class,
BugCheckerRules.class,
CollectionRules.class,
ComparatorRules.class,
DoubleStreamRules.class,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package tech.picnic.errorprone.refasterrules;

import com.google.common.collect.ImmutableSet;
import com.google.errorprone.BugCheckerRefactoringTestHelper;
import com.google.errorprone.BugCheckerRefactoringTestHelper.FixChoosers;
import tech.picnic.errorprone.bugpatterns.StringCaseLocaleUsage;
import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase;

final class BugCheckerRulesTest implements RefasterRuleCollectionTestCase {
@Override
public ImmutableSet<?> elidedTypesAndStaticImports() {
return ImmutableSet.of(FixChoosers.class);
}

BugCheckerRefactoringTestHelper testSetFixChooserDefault() {
return BugCheckerRefactoringTestHelper.newInstance(StringCaseLocaleUsage.class, getClass())
.setFixChooser(FixChoosers.FIRST);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package tech.picnic.errorprone.refasterrules;

import com.google.common.collect.ImmutableSet;
import com.google.errorprone.BugCheckerRefactoringTestHelper;
import com.google.errorprone.BugCheckerRefactoringTestHelper.FixChoosers;
import tech.picnic.errorprone.bugpatterns.StringCaseLocaleUsage;
import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase;

final class BugCheckerRulesTest implements RefasterRuleCollectionTestCase {
@Override
public ImmutableSet<?> elidedTypesAndStaticImports() {
return ImmutableSet.of(FixChoosers.class);
}

BugCheckerRefactoringTestHelper testSetFixChooserDefault() {
return BugCheckerRefactoringTestHelper.newInstance(StringCaseLocaleUsage.class, getClass());
}
}

0 comments on commit a4096e9

Please sign in to comment.