Skip to content

Commit c224929

Browse files
committed
Remove all of FormatExceptionPolicy except Strict, which remains for easy API conversion.
1 parent a94dce9 commit c224929

File tree

4 files changed

+10
-63
lines changed

4 files changed

+10
-63
lines changed

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

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

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 DiffPlug
2+
* Copyright 2016-2024 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.
@@ -23,7 +23,7 @@
2323
* A policy for handling exceptions in the format. Any exceptions will
2424
* halt the build except for a specifically excluded path or step.
2525
*/
26-
public class FormatExceptionPolicyStrict extends NoLambda.EqualityBasedOnSerialization implements FormatExceptionPolicy {
26+
public class FormatExceptionPolicyStrict extends NoLambda.EqualityBasedOnSerialization {
2727
private static final long serialVersionUID = 1L;
2828

2929
private final Set<String> excludeSteps = new TreeSet<>();
@@ -39,18 +39,17 @@ public void excludePath(String relativePath) {
3939
excludePaths.add(Objects.requireNonNull(relativePath));
4040
}
4141

42-
@Override
4342
public void handleError(Throwable e, FormatterStep step, String relativePath) {
4443
Objects.requireNonNull(e, "e");
4544
Objects.requireNonNull(step, "step");
4645
Objects.requireNonNull(relativePath, "relativePath");
4746
if (excludeSteps.contains(step.getName())) {
48-
FormatExceptionPolicyLegacy.warning(e, step, relativePath);
47+
LintPolicy.warning(e, step, relativePath);
4948
} else {
5049
if (excludePaths.contains(relativePath)) {
51-
FormatExceptionPolicyLegacy.warning(e, step, relativePath);
50+
LintPolicy.warning(e, step, relativePath);
5251
} else {
53-
FormatExceptionPolicyLegacy.error(e, step, relativePath);
52+
LintPolicy.error(e, step, relativePath);
5453
throw ThrowingEx.asRuntimeRethrowError(e);
5554
}
5655
}

lib/src/main/java/com/diffplug/spotless/FormatExceptionPolicyLegacy.java renamed to lib/src/main/java/com/diffplug/spotless/LintPolicy.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2022 DiffPlug
2+
* Copyright 2024 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.
@@ -18,21 +18,9 @@
1818
import org.slf4j.Logger;
1919
import org.slf4j.LoggerFactory;
2020

21-
class FormatExceptionPolicyLegacy extends NoLambda.EqualityBasedOnSerialization implements FormatExceptionPolicy {
22-
private static final long serialVersionUID = 1L;
23-
21+
class LintPolicy {
2422
private static final Logger logger = LoggerFactory.getLogger(Formatter.class);
2523

26-
@Override
27-
public void handleError(Throwable e, FormatterStep step, String relativePath) {
28-
if (e instanceof Error) {
29-
error(e, step, relativePath);
30-
throw ((Error) e);
31-
} else {
32-
warning(e, step, relativePath);
33-
}
34-
}
35-
3624
static void error(Throwable e, FormatterStep step, String relativePath) {
3725
logger.error("Step '{}' found problem in '{}':\n{}", step.getName(), relativePath, e.getMessage(), e);
3826
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.gradle.api.tasks.PathSensitivity;
3838
import org.gradle.work.Incremental;
3939

40-
import com.diffplug.spotless.FormatExceptionPolicy;
4140
import com.diffplug.spotless.FormatExceptionPolicyStrict;
4241
import com.diffplug.spotless.Formatter;
4342
import com.diffplug.spotless.FormatterStep;
@@ -115,14 +114,14 @@ public ObjectId getRatchetSha() {
115114
return subtreeSha;
116115
}
117116

118-
protected FormatExceptionPolicy exceptionPolicy = new FormatExceptionPolicyStrict();
117+
protected FormatExceptionPolicyStrict exceptionPolicy = new FormatExceptionPolicyStrict();
119118

120-
public void setExceptionPolicy(FormatExceptionPolicy exceptionPolicy) {
119+
public void setExceptionPolicy(FormatExceptionPolicyStrict exceptionPolicy) {
121120
this.exceptionPolicy = Objects.requireNonNull(exceptionPolicy);
122121
}
123122

124123
@Input
125-
public FormatExceptionPolicy getExceptionPolicy() {
124+
public FormatExceptionPolicyStrict getExceptionPolicy() {
126125
return exceptionPolicy;
127126
}
128127

0 commit comments

Comments
 (0)