Skip to content

Commit 9658d41

Browse files
committed
Improve LintState's toString.
1 parent 8300fda commit 9658d41

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,19 @@ public String asString(File file, Formatter formatter) {
7272
if (lints != null) {
7373
FormatterStep step = formatter.getSteps().get(i);
7474
for (Lint lint : lints) {
75-
result.append(file.getName()).append(":").append(lint.getLineStart());
76-
if (lint.getLineEnd() != lint.getLineStart()) {
77-
result.append("-").append(lint.getLineEnd());
75+
result.append(file.getName()).append(":");
76+
if (lint.getLineStart() == Lint.LINE_UNDEFINED) {
77+
result.append("LINE_UNDEFINED");
78+
} else {
79+
result.append("L");
80+
result.append(lint.getLineStart());
81+
if (lint.getLineEnd() != lint.getLineStart()) {
82+
result.append("-").append(lint.getLineEnd());
83+
}
7884
}
7985
result.append(" ");
80-
result.append(step.getName()).append("(").append(lint.getCode()).append(") ");
81-
result.append(lint.getMsg());
86+
result.append(step.getName()).append("(").append(lint.getRuleId()).append(") ");
87+
result.append(lint.getDetail());
8288
result.append("\n");
8389
}
8490
}
@@ -111,7 +117,7 @@ public static LintState of(Formatter formatter, File file, byte[] rawBytes) {
111117
lints.set(i, lintsForStep);
112118
}
113119
} catch (Exception e) {
114-
lints.set(i, List.of(Lint.createFromThrowable(step, toLint, e)));
120+
lints.set(i, List.of(Lint.createFromThrowable(step, e)));
115121
}
116122
}
117123
}
@@ -142,7 +148,7 @@ public static LintState of(Formatter formatter, File file, byte[] rawBytes) {
142148
if (exceptionForLint instanceof Lint.Has) {
143149
lintsForStep = ((Lint.Has) exceptionForLint).getLints();
144150
} else if (exceptionForLint != null && exceptionForLint != formatStepCausedNoChange()) {
145-
lintsForStep = List.of(Lint.createFromThrowable(step, toLint, exceptionForLint));
151+
lintsForStep = List.of(Lint.createFromThrowable(step, exceptionForLint));
146152
} else {
147153
lintsForStep = List.of();
148154
}

0 commit comments

Comments
 (0)