Skip to content

Commit c8abb01

Browse files
author
Vincent Potucek
committed
[prone] Add RedundantStringConversion
1 parent 1be6a54 commit c8abb01

File tree

6 files changed

+27
-5
lines changed

6 files changed

+27
-5
lines changed

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ plugins {
2020

2121
description = "Spring Boot Build"
2222

23-
defaultTasks 'build'
23+
defaultTasks "build"
2424

2525
allprojects {
2626
group = "org.springframework.boot"
27+
apply from: rootProject.file("gradle/error-prone.gradle")
2728
}
2829

2930
subprojects {

cli/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/AnsiString.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ AnsiString append(String text, Code... codes) {
5555
for (Code code : codes) {
5656
ansi = applyCode(ansi, code);
5757
}
58-
this.value.append(ansi.a(text).reset().toString());
58+
this.value.append(ansi.a(text).reset());
5959
return this;
6060
}
6161

core/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/Elements.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static String getQualifiedName(Element element) {
3636
TypeElement enclosingElement = getEnclosingTypeElement(element.asType());
3737
if (enclosingElement != null) {
3838
return getQualifiedName(enclosingElement) + "$"
39-
+ ((DeclaredType) element.asType()).asElement().getSimpleName().toString();
39+
+ ((DeclaredType) element.asType()).asElement().getSimpleName();
4040
}
4141
if (element instanceof TypeElement typeElement) {
4242
return typeElement.getQualifiedName().toString();

core/spring-boot/src/main/java/org/springframework/boot/context/properties/source/FilteredConfigurationPropertiesSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected Predicate<ConfigurationPropertyName> getFilter() {
7373

7474
@Override
7575
public String toString() {
76-
return this.source.toString() + " (filtered)";
76+
return this.source + " (filtered)";
7777
}
7878

7979
}

gradle/error-prone.gradle

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
}
9+
10+
tasks.withType(JavaCompile).configureEach {
11+
options.errorprone {
12+
disableAllChecks = true
13+
error("RedundantStringConversion")
14+
if (!getenv().containsKey("CI") && getenv("IN_PLACE")?.toBoolean()) {
15+
errorproneArgs.addAll(
16+
"-XepPatchLocation:IN_PLACE",
17+
"-XepPatchChecks:RedundantStringConversion"
18+
)
19+
}
20+
}
21+
}

module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/PlainTextThreadDumpFormatter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private List<MonitorInfo> lockedMonitorsForDepth(MonitorInfo[] lockedMonitors, i
7777

7878
private void writeStackTraceElement(PrintWriter writer, StackTraceElement element, ThreadInfo info,
7979
List<MonitorInfo> lockedMonitors, boolean firstElement) {
80-
writer.printf("\tat %s%n", element.toString());
80+
writer.printf("\tat %s%n", element);
8181
LockInfo lockInfo = info.getLockInfo();
8282
if (firstElement && lockInfo != null) {
8383
if (element.getClassName().equals(Object.class.getName()) && element.getMethodName().equals("wait")) {

0 commit comments

Comments
 (0)