-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce rule to drop default setFixChooser
- Loading branch information
Bastien Diederichs
committed
Mar 10, 2023
1 parent
c3cd535
commit a4096e9
Showing
5 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/BugCheckerRules.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...rib/src/test/resources/tech/picnic/errorprone/refasterrules/BugCheckerRulesTestInput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ib/src/test/resources/tech/picnic/errorprone/refasterrules/BugCheckerRulesTestOutput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |