Skip to content

Commit 3e0e1ba

Browse files
author
Vincent Potucek
committed
Add RedundantStringConversion
1 parent 036c0b0 commit 3e0e1ba

File tree

8 files changed

+39
-7
lines changed

8 files changed

+39
-7
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ repositories {
1212
apply from: rootProject.file('gradle/java-publish.gradle')
1313
apply from: rootProject.file('gradle/changelog.gradle')
1414
allprojects {
15+
apply from: rootProject.file('gradle/error-prone.gradle')
1516
apply from: rootProject.file('gradle/rewrite.gradle')
1617
apply from: rootProject.file('gradle/spotless.gradle')
1718
}

gradle/error-prone.gradle

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import static java.lang.System.getenv
2+
3+
apply plugin: 'net.ltgt.errorprone'
4+
5+
dependencies {
6+
errorprone('com.google.errorprone:error_prone_core:2.42.0')
7+
errorprone('tech.picnic.error-prone-support:error-prone-contrib:0.25.0')
8+
constraints {
9+
errorprone('com.google.guava:guava') {
10+
version {
11+
require('33.4.8-jre')
12+
}
13+
because('Older versions use deprecated methods in sun.misc.Unsafe')
14+
// https://github.com/junit-team/junit-framework/pull/5039#discussion_r2414490581
15+
}
16+
}
17+
}
18+
19+
tasks.withType(JavaCompile).configureEach {
20+
options.errorprone {
21+
disableAllChecks = true // consider removal to avoid error prone error´s, following convention over configuration.
22+
error('RedundantStringConversion')
23+
if (!getenv().containsKey('CI') && getenv('IN_PLACE')?.toBoolean()) {
24+
errorproneArgs.addAll(
25+
'-XepPatchLocation:IN_PLACE',
26+
'-XepPatchChecks:RedundantStringConversion'
27+
)
28+
}
29+
}
30+
}

lib/src/main/java/com/diffplug/spotless/ForeignExe.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ private RuntimeException exceptionFmt(String msgPrimary, ProcessRunner.Result cm
134134
errorMsg.append(msgFix);
135135
errorMsg.append('\n');
136136
}
137-
errorMsg.append(cmd.toString());
137+
errorMsg.append(cmd);
138138
return new RuntimeException(errorMsg.toString());
139139
}
140140
}

lib/src/main/java/com/diffplug/spotless/biome/BiomeExecutableDownloader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ private Path getChecksumPath(Path file) {
261261
var parent = file.getParent();
262262
var base = parent != null ? parent : file;
263263
var fileName = file.getFileName();
264-
var checksumName = fileName != null ? fileName.toString() + ".sha256" : "checksum.sha256";
264+
var checksumName = fileName != null ? fileName + ".sha256" : "checksum.sha256";
265265
return base.resolve(checksumName);
266266
}
267267

lib/src/main/java/com/diffplug/spotless/sql/dbeaver/SQLTokensParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ else if (contains(singleLineCommentStart, fChar)) {
186186
s.append(fChar);
187187
}
188188
}
189-
return new FormatterToken(TokenType.COMMAND, word + s.toString(), start_pos);
189+
return new FormatterToken(TokenType.COMMAND, word + s, start_pos);
190190
}
191191
if (sqlDialect.getKeywordType(word) != null) {
192192
return new FormatterToken(TokenType.KEYWORD, word, start_pos);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ private void writePomWithLintSuppressions(String... stepsAndSuppressions) throws
161161
}
162162

163163
// Create the configuration
164-
String javaGroup = "<java>" + javaSteps.toString() + "</java>";
165-
String fullConfiguration = javaGroup + globalConfig.toString();
164+
String javaGroup = "<java>" + javaSteps + "</java>";
165+
String fullConfiguration = javaGroup + globalConfig;
166166

167167
writePom(fullConfiguration);
168168
}

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ plugins {
2424
// https://github.com/equodev/equo-ide/blob/main/plugin-gradle/CHANGELOG.md
2525
id 'dev.equo.ide' version '1.7.8' apply false
2626
id 'org.openrewrite.rewrite' version '7.18.0' apply false
27+
id 'net.ltgt.errorprone' version '4.3.0' apply false
2728
}
2829

2930
dependencyResolutionManagement {

testlib/src/main/java/com/diffplug/spotless/ReflectionUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 DiffPlug
2+
* Copyright 2016-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@ public static void dumpAllInfo(String name, Object obj) {
3737

3838
public static void dumpMethod(Method method) {
3939
System.out.print(Modifier.toString(method.getModifiers()));
40-
System.out.print(" " + method.getReturnType().toString());
40+
System.out.print(" " + method.getReturnType());
4141
System.out.print(" " + method.getName() + "(");
4242
Iterator<Parameter> paramIter = Arrays.asList(method.getParameters()).iterator();
4343
while (paramIter.hasNext()) {

0 commit comments

Comments
 (0)