Skip to content

Commit 01f73c0

Browse files
committed
Fix spotbugs warnings in FenceStep.
1 parent 2991b26 commit 01f73c0

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/src/main/java/com/diffplug/spotless/generic/FenceStep.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import com.diffplug.spotless.FormatterStep;
3030
import com.diffplug.spotless.LineEnding;
3131

32+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
33+
3234
public class FenceStep {
3335
/** Declares the name of the step. */
3436
public static FenceStep named(String name) {
@@ -94,6 +96,8 @@ public FormatterStep applyWithin(List<FormatterStep> steps) {
9496
}
9597

9698
static class ApplyWithin extends Apply implements FormatterFunc.Closeable.ResourceFuncNeedsFile<Formatter> {
99+
private static final long serialVersionUID = 17061466531957339L;
100+
97101
ApplyWithin(Pattern regex, List<FormatterStep> steps) {
98102
super(regex, steps);
99103
}
@@ -112,6 +116,8 @@ public String apply(Formatter formatter, String unix, File file) throws Exceptio
112116
}
113117

114118
static class PreserveWithin extends Apply implements FormatterFunc.Closeable.ResourceFuncNeedsFile<Formatter> {
119+
private static final long serialVersionUID = -8676786492305178343L;
120+
115121
PreserveWithin(Pattern regex, List<FormatterStep> steps) {
116122
super(regex, steps);
117123
}
@@ -133,7 +139,9 @@ public String apply(Formatter formatter, String unix, File file) throws Exceptio
133139
}
134140
}
135141

142+
@SuppressFBWarnings("SE_TRANSIENT_FIELD_NOT_RESTORED")
136143
static class Apply implements Serializable {
144+
private static final long serialVersionUID = -2301848328356559915L;
137145
final Pattern regex;
138146
final List<FormatterStep> steps;
139147

@@ -189,8 +197,9 @@ protected String assembleGroups(String unix) {
189197
builder.append(unix, lastEnd, unix.length());
190198
return builder.toString();
191199
} else {
192-
int startLine = 1 + (int) builder.toString().codePoints().filter(c -> c == '\n').count();
193-
int endLine = 1 + (int) unix.codePoints().filter(c -> c == '\n').count();
200+
// these will be needed to generate Lints later on
201+
// int startLine = 1 + (int) builder.toString().codePoints().filter(c -> c == '\n').count();
202+
// int endLine = 1 + (int) unix.codePoints().filter(c -> c == '\n').count();
194203

195204
// throw an error with either the full regex, or the nicer open/close pair
196205
Matcher openClose = Pattern.compile("\\\\Q([\\s\\S]*?)\\\\E" + "\\Q([\\s\\S]*?)\\E" + "\\\\Q([\\s\\S]*?)\\\\E")

0 commit comments

Comments
 (0)