Skip to content

Commit dfc6c6b

Browse files
committed
Apply recipe best practices
1 parent e5b48c2 commit dfc6c6b

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

src/main/java/org/openrewrite/maven/ConfigurableRewriteMojo.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@
3535
import java.nio.file.Paths;
3636
import java.util.*;
3737

38-
import static java.util.Collections.emptyMap;
39-
import static java.util.Collections.emptySet;
40-
import static java.util.Collections.unmodifiableSet;
38+
import static java.util.Collections.*;
4139
import static java.util.stream.Collectors.toCollection;
4240
import static org.openrewrite.java.style.CheckstyleConfigLoader.loadCheckstyleConfig;
4341

src/test/java/org/openrewrite/maven/RewriteRunIT.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ void multi_source_sets_project(MavenExecutionResult result) {
5252
.isSuccessful()
5353
.out()
5454
.warn()
55-
.contains(String.format("Changes have been made to %s by:", separatorsToSystem("project/src/integration-test/java/sample/IntegrationTest.java")))
56-
.contains(String.format("Changes have been made to %s by:", separatorsToSystem("project/src/test/java/sample/RegularTest.java")));
55+
.contains("Changes have been made to %s by:".formatted(separatorsToSystem("project/src/integration-test/java/sample/IntegrationTest.java")))
56+
.contains("Changes have been made to %s by:".formatted(separatorsToSystem("project/src/test/java/sample/RegularTest.java")));
5757
}
5858

5959
@MavenTest
@@ -100,7 +100,7 @@ void cloud_suitability_project(MavenExecutionResult result) {
100100
void command_line_options(MavenExecutionResult result) {
101101
assertThat(result).isSuccessful().out().error().isEmpty();
102102
assertThat(result).isSuccessful().out().warn()
103-
.contains(String.format("Changes have been made to %s by:", separatorsToSystem("project/pom.xml")))
103+
.contains("Changes have been made to %s by:".formatted(separatorsToSystem("project/pom.xml")))
104104
.contains(" org.openrewrite.maven.RemovePlugin: {groupId=org.openrewrite.maven, artifactId=rewrite-maven-plugin}");
105105
assertThat(result.getMavenProjectResult().getModel().getBuild()).isNull();
106106
}
@@ -116,7 +116,7 @@ void command_line_options_json(MavenExecutionResult result) {
116116
.isSuccessful()
117117
.out()
118118
.warn()
119-
.contains(String.format("Changes have been made to %s by:", separatorsToSystem("project/src/main/java/sample/SomeClass.java")))
119+
.contains("Changes have been made to %s by:".formatted(separatorsToSystem("project/src/main/java/sample/SomeClass.java")))
120120
.contains(" org.openrewrite.java.AddCommentToMethod: {comment='{\"test\":{\"some\":\"yeah\"}}', methodPattern=sample.SomeClass doTheThing(..)}");
121121
}
122122

@@ -148,10 +148,10 @@ void container_masks(MavenExecutionResult result) {
148148
.out()
149149
.warn()
150150
.contains(
151-
String.format("Changes have been made to %s by:", separatorsToSystem("project/containerfile.build")),
152-
String.format("Changes have been made to %s by:", separatorsToSystem("project/Dockerfile")),
153-
String.format("Changes have been made to %s by:", separatorsToSystem("project/Containerfile")),
154-
String.format("Changes have been made to %s by:", separatorsToSystem("project/build.dockerfile"))
151+
"Changes have been made to %s by:".formatted(separatorsToSystem("project/containerfile.build")),
152+
"Changes have been made to %s by:".formatted(separatorsToSystem("project/Dockerfile")),
153+
"Changes have been made to %s by:".formatted(separatorsToSystem("project/Containerfile")),
154+
"Changes have been made to %s by:".formatted(separatorsToSystem("project/build.dockerfile"))
155155
);
156156
}
157157

@@ -163,10 +163,10 @@ void plaintext_masks(MavenExecutionResult result) {
163163
.out()
164164
.warn()
165165
.contains(
166-
String.format("Changes have been made to %s by:", separatorsToSystem("project/src/main/java/sample/in-src.ext")),
167-
String.format("Changes have been made to %s by:", separatorsToSystem("project/.in-root")),
168-
String.format("Changes have been made to %s by:", separatorsToSystem("project/from-default-list.py")),
169-
String.format("Changes have been made to %s by:", separatorsToSystem("project/src/main/java/sample/Dummy.java"))
166+
"Changes have been made to %s by:".formatted(separatorsToSystem("project/src/main/java/sample/in-src.ext")),
167+
"Changes have been made to %s by:".formatted(separatorsToSystem("project/.in-root")),
168+
"Changes have been made to %s by:".formatted(separatorsToSystem("project/from-default-list.py")),
169+
"Changes have been made to %s by:".formatted(separatorsToSystem("project/src/main/java/sample/Dummy.java"))
170170
)
171171
.doesNotContain("in-root.ignored");
172172
}

src/test/java/org/openrewrite/maven/RewriteTypeTableIT.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import com.soebes.itf.jupiter.extension.*;
1919
import com.soebes.itf.jupiter.maven.MavenExecutionResult;
20-
import org.openrewrite.PathUtils;
2120

2221
import static com.soebes.itf.extension.assertj.MavenITAssertions.assertThat;
2322
import static org.openrewrite.PathUtils.separatorsToSystem;
@@ -38,7 +37,7 @@ void typetable_default(MavenExecutionResult result) {
3837
"contains guava 33.3.1-jre")
3938
.matches(logLines -> logLines.stream().anyMatch(line -> line.contains("Wrote com.google.guava:guava:jar:32.0.0-jre")),
4039
"contains guava 32.0.0-jre")
41-
.matches(logLines -> logLines.stream().anyMatch(line -> line.contains(String.format("Wrote %s", separatorsToSystem("src/main/resources/META-INF/rewrite/classpath.tsv.gz")))),
40+
.matches(logLines -> logLines.stream().anyMatch(line -> line.contains("Wrote %s".formatted(separatorsToSystem("src/main/resources/META-INF/rewrite/classpath.tsv.gz")))),
4241
"write classpath.tsv.gz");
4342
assertThat(result).out().error().isEmpty();
4443
}

0 commit comments

Comments
 (0)