Skip to content

Commit 5bcabf8

Browse files
author
Vincent Potucek
committed
[prone] Apply UseTextBlocks
1 parent ffb7c59 commit 5bcabf8

7 files changed

Lines changed: 29 additions & 35 deletions

File tree

lib/src/main/java/com/diffplug/spotless/generic/IdeaStep.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,12 @@ private static String resolveFullBinaryPathAndCheckVersion(String binaryPath) {
158158
.pathToExe(pathToExe(binaryPath))
159159
.versionRegex(Pattern.compile("(IntelliJ IDEA) .*"))
160160
.fixCantFind(
161-
"IDEA executable cannot be found on your machine, "
162-
+ "please install it and put idea binary to PATH, provide a valid path to the executable or report the problem")
163-
.fixWrongVersion("Provided binary is not IDEA, "
164-
+ "please check it and fix the problem; or report the problem");
161+
"""
162+
IDEA executable cannot be found on your machine, \
163+
please install it and put idea binary to PATH, provide a valid path to the executable or report the problem""")
164+
.fixWrongVersion("""
165+
Provided binary is not IDEA, \
166+
please check it and fix the problem; or report the problem""");
165167
try {
166168
return exe.confirmVersionAndGetAbsolutePath();
167169
} catch (IOException e) {

lib/src/main/java/com/diffplug/spotless/go/GofmtFormatStep.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ public FormatterStep create() {
6767
}
6868

6969
private RoundtripState createRountrip() throws IOException, InterruptedException {
70-
String howToInstall = "gofmt is a part of standard go distribution. If spotless can't discover it automatically, "
71-
+ "you can point Spotless to the go binary with {@code pathToExe('/path/to/go')}";
70+
String howToInstall = """
71+
gofmt is a part of standard go distribution. If spotless can't discover it automatically, \
72+
you can point Spotless to the go binary with {@code pathToExe('/path/to/go')}\
73+
""";
7274
final ForeignExe exe = ForeignExe.nameAndVersion("go", version)
7375
.pathToExe(pathToExe)
7476
.versionFlag("version")

lib/src/main/java/com/diffplug/spotless/rdf/ReflectionHelper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,9 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
205205
logger.warn("{}({},{}): {}", this.filePath, line, col, message);
206206
} else {
207207
if ("warning".equals(severity)) {
208-
logger.error("Formatter fails because of a parser warning. To make the formatter succeed in"
209-
+ "the presence of warnings, set the configuration parameter 'failOnWarning' to 'false' (default: 'true')");
208+
logger.error("""
209+
Formatter fails because of a parser warning. To make the formatter succeed in\
210+
the presence of warnings, set the configuration parameter 'failOnWarning' to 'false' (default: 'true')""");
210211
}
211212
throw new RuntimeException(
212213
"line %d, col %d: %s (severity: %s)".formatted(line, col, message, severity));

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GradleProvisioner.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,9 @@ private static Provisioner forConfigurationContainer(Project project, Configurat
135135
projName = projName + "/";
136136
}
137137
throw new GradleException(String.format(
138-
"You need to add a repository containing the '%s' artifact in '%sbuild.gradle'.%n"
139-
+ "E.g.: 'repositories { mavenCentral() }'",
138+
"""
139+
You need to add a repository containing the '%s' artifact in '%sbuild.gradle'.%n\
140+
E.g.: 'repositories { mavenCentral() }'""",
140141
mavenCoords, projName), e);
141142
}
142143
};

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/TargetExcludeIfContentContainsTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ void targetExcludeIfContentContainsWithMultipleSteps() throws IOException {
6060
" target '**/*.md'",
6161
" targetExcludeIfContentContains '// Generated by Mr. Roboto'",
6262
" custom 'lowercase', { str -> str.toLowerCase() }",
63-
" licenseHeader('" + "// My CopyRights header" + "', '--')",
63+
"""
64+
licenseHeader('\
65+
// My CopyRights header\
66+
', '--')""",
6467
" }",
6568
"}");
6669
String generatedContent = """

plugin-maven/src/test/java/com/diffplug/spotless/maven/MavenIntegrationHarness.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,13 @@ void gitAttributes() throws IOException {
9393
if (Jvm.version() >= 16) {
9494
// for GJF https://github.com/diffplug/spotless/issues/834
9595
setFile(".mvn/jvm.config").toContent(
96-
"--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"
97-
+ " --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED"
98-
+ " --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED"
99-
+ " --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED"
100-
+ " --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
101-
// this last line is for Detekt
102-
+ // this last line is for Detekt
103-
" --add-opens java.base/java.lang=ALL-UNNAMED");
96+
"""
97+
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED\
98+
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED\
99+
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED\
100+
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED\
101+
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED\
102+
--add-opens java.base/java.lang=ALL-UNNAMED""");
104103
}
105104
// copy the mvnw resources
106105
copy("mvnw").setExecutable(true);

rewrite.yml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ recipeList:
1717
- org.openrewrite.java.format.NormalizeLineBreaks
1818
- org.openrewrite.java.format.RemoveTrailingWhitespace
1919
- org.openrewrite.java.migrate.UpgradeToJava17
20+
- org.openrewrite.java.migrate.lang.UseTextBlocks
2021
- org.openrewrite.java.migrate.util.JavaUtilAPIs
2122
- org.openrewrite.java.migrate.util.MigrateInflaterDeflaterToClose
2223
- org.openrewrite.java.migrate.util.ReplaceStreamCollectWithToList
@@ -68,22 +69,7 @@ styleConfigs:
6869
- org.openrewrite.java.style.ImportLayoutStyle:
6970
classCountToUseStarImport: 999
7071
nameCountToUseStarImport: 999
71-
# bug https://github.com/openrewrite/rewrite/issues/6107
72-
# layout:
73-
# - import java.*
74-
# - <blank line>
75-
# - import javax.*
76-
# - <blank line>
77-
# - import org.*
78-
# - <blank line>
79-
# - import com.*
80-
# - <blank line>
81-
# - import com.diffplug.*
82-
# - <blank line>
83-
# - import static all other imports
84-
# - <blank line>
85-
# - import all other imports
86-
# - <blank line>
72+
# no layout needed, we use spotless
8773
- org.openrewrite.java.style.TabsAndIndentsStyle:
8874
useTabCharacter: true
8975
tabSize: 4

0 commit comments

Comments
 (0)