Skip to content

Commit 49b6e85

Browse files
timtebeekTeamModerne
authored andcommitted
Replace getTags() method with field
Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.java.recipes.UseTagsField?organizationId=QUxML01vZGVybmUvTW9kZXJuZSArIE9wZW5SZXdyaXRl Co-authored-by: Moderne <team@moderne.io>
1 parent cec049e commit 49b6e85

8 files changed

Lines changed: 14 additions & 32 deletions

src/main/java/org/openrewrite/java/testing/assertj/SimplifyChainedAssertJAssertion.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,8 @@ public class SimplifyChainedAssertJAssertion extends Recipe {
7373
@Getter
7474
final String displayName = "Simplify AssertJ chained assertions";
7575

76-
@Override
77-
public Set<String> getTags() {
78-
return singleton("RSPEC-S5838");
79-
}
76+
@Getter
77+
final Set<String> tags = singleton("RSPEC-S5838");
8078

8179
@Getter
8280
final String description = "Many AssertJ chained assertions have dedicated assertions that function the same. " +

src/main/java/org/openrewrite/java/testing/cleanup/AssertionsArgumentOrder.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,8 @@ public class AssertionsArgumentOrder extends Recipe {
9090
@Getter
9191
final String description = "Assertions such as `org.junit.Assert.assertEquals` expect the first argument to be the expected value and the second argument to be the actual value; for `org.testng.Assert`, it’s the other way around. This recipe detects `J.Literal`, `J.NewArray`, and `java.util.Iterable` arguments swapping them if necessary so that the error messages won't be confusing.";
9292

93-
@Override
94-
public Set<String> getTags() {
95-
return singleton("RSPEC-S3415");
96-
}
93+
@Getter
94+
final Set<String> tags = singleton("RSPEC-S3415");
9795

9896
@Override
9997
public TreeVisitor<?, ExecutionContext> getVisitor() {

src/main/java/org/openrewrite/java/testing/cleanup/RemoveEmptyTests.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ public Duration getEstimatedEffortPerOccurrence() {
4444
return Duration.ofMinutes(2);
4545
}
4646

47-
@Override
48-
public Set<String> getTags() {
49-
return singleton("RSPEC-S1186");
50-
}
47+
@Getter
48+
final Set<String> tags = singleton("RSPEC-S1186");
5149

5250
@Override
5351
public TreeVisitor<?, ExecutionContext> getVisitor() {

src/main/java/org/openrewrite/java/testing/cleanup/TestsShouldIncludeAssertions.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,7 @@ public class TestsShouldIncludeAssertions extends Recipe {
7171

7272
String description = "For tests not having any assertions, wrap the statements with JUnit Jupiter's `Assertions#assertDoesNotThrow(..)`.";
7373

74-
@Override
75-
public Set<String> getTags() {
76-
return singleton("RSPEC-S2699");
77-
}
74+
Set<String> tags = singleton("RSPEC-S2699");
7875

7976
@Override
8077
public Validated<Object> validate() {

src/main/java/org/openrewrite/java/testing/cleanup/TestsShouldNotBePublic.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,8 @@ public class TestsShouldNotBePublic extends ScanningRecipe<TestsShouldNotBePubli
5757
@Getter
5858
final String description = "Remove `public` and optionally `protected` modifiers from methods with `@Test`, `@ParameterizedTest`, `@RepeatedTest`, `@TestFactory`, `@BeforeEach`, `@AfterEach`, `@BeforeAll`, or `@AfterAll`. They no longer have to be public visibility to be usable by JUnit 5.";
5959

60-
@Override
61-
public Set<String> getTags() {
62-
return singleton("RSPEC-S5786");
63-
}
60+
@Getter
61+
final Set<String> tags = singleton("RSPEC-S5786");
6462

6563
@Override
6664
public Accumulator getInitialValue(ExecutionContext ctx) {

src/main/java/org/openrewrite/java/testing/junit5/AddMissingNested.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ public Duration getEstimatedEffortPerOccurrence() {
6262
return Duration.ofMinutes(1);
6363
}
6464

65-
@Override
66-
public Set<String> getTags() {
67-
return singleton("RSPEC-S5790");
68-
}
65+
Set<String> tags = singleton("RSPEC-S5790");
6966

7067
@Override
7168
public TreeVisitor<?, ExecutionContext> getVisitor() {

src/main/java/org/openrewrite/java/testing/junit5/RemoveTryCatchFailBlocks.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ public class RemoveTryCatchFailBlocks extends Recipe {
4444
final String description = "Replace `try-catch` blocks where `catch` merely contains a `fail()` for `fail(String)` statement " +
4545
"with `Assertions.assertDoesNotThrow(() -> { ... })`.";
4646

47-
@Override
48-
public Set<String> getTags() {
49-
return singleton("RSPEC-S3658");
50-
}
47+
@Getter
48+
final Set<String> tags = singleton("RSPEC-S3658");
5149

5250
@Override
5351
public TreeVisitor<?, ExecutionContext> getVisitor() {

src/main/java/org/openrewrite/java/testing/mockito/SimplifyMockitoVerifyWhenGiven.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ public class SimplifyMockitoVerifyWhenGiven extends Recipe {
4949
@Getter
5050
final String description = "Fixes Sonar issue `java:S6068`: Call to Mockito method \"verify\", \"when\" or \"given\" should be simplified.";
5151

52-
@Override
53-
public Set<String> getTags() {
54-
return singleton("RSPEC-6068");
55-
}
52+
@Getter
53+
final Set<String> tags = singleton("RSPEC-6068");
5654

5755
@Override
5856
public TreeVisitor<?, ExecutionContext> getVisitor() {

0 commit comments

Comments
 (0)