Skip to content

Commit ffc7919

Browse files
committed
Delete the unneeded LintPolicy.
1 parent a36b44b commit ffc7919

File tree

3 files changed

+17
-37
lines changed

3 files changed

+17
-37
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public static DirtyState of(Formatter formatter, File file, byte[] rawBytes) {
8080
public static DirtyState of(Formatter formatter, File file, byte[] rawBytes, String raw) {
8181
var valuePerStep = new ValuePerStep<Throwable>(formatter);
8282
DirtyState state = of(formatter, file, rawBytes, raw, valuePerStep);
83-
LintPolicy.legacyBehavior(formatter, file, valuePerStep);
83+
Formatter.legacyErrorBehavior(formatter, file, valuePerStep);
8484
return state;
8585
}
8686

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
import java.util.List;
2929
import java.util.Objects;
3030

31+
import org.slf4j.Logger;
32+
import org.slf4j.LoggerFactory;
33+
3134
/** Formatter which performs the full formatting. */
3235
public final class Formatter implements Serializable, AutoCloseable {
3336
private static final long serialVersionUID = 1L;
@@ -130,10 +133,22 @@ public String computeLineEndings(String unix, File file) {
130133
public String compute(String unix, File file) {
131134
ValuePerStep<Throwable> exceptionPerStep = new ValuePerStep<>(this);
132135
String result = computeWithLint(unix, file, exceptionPerStep);
133-
LintPolicy.legacyBehavior(this, file, exceptionPerStep);
136+
legacyErrorBehavior(this, file, exceptionPerStep);
134137
return result;
135138
}
136139

140+
static void legacyErrorBehavior(Formatter formatter, File file, ValuePerStep<Throwable> exceptionPerStep) {
141+
for (int i = 0; i < formatter.getSteps().size(); ++i) {
142+
Throwable exception = exceptionPerStep.get(i);
143+
if (exception != null && exception != LintState.formatStepCausedNoChange()) {
144+
logger.error("Step '{}' found problem in '{}':\n{}", formatter.getSteps().get(i), file.getName(), exception.getMessage(), exception);
145+
throw ThrowingEx.asRuntimeRethrowError(exception);
146+
}
147+
}
148+
}
149+
150+
private static final Logger logger = LoggerFactory.getLogger(Formatter.class);
151+
137152
/**
138153
* Returns the result of calling all of the FormatterSteps, while also
139154
* tracking any exceptions which are thrown.

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

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)