Skip to content

Commit b2eb9ac

Browse files
committed
Minor refactor to improve.
1 parent d245591 commit b2eb9ac

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ protected List<LintSuppression> getLintSuppressions() {
228228
return lintSuppressions;
229229
}
230230

231-
protected abstract void process(String name, Iterable<File> files, Formatter formatter, UpToDateChecker upToDateChecker, FormatterConfig config) throws MojoExecutionException;
231+
protected abstract void process(String name, Iterable<File> files, Formatter formatter, UpToDateChecker upToDateChecker, List<LintSuppression> lintSuppressions) throws MojoExecutionException;
232232

233233
private static final int MINIMUM_JRE = 11;
234234

@@ -261,7 +261,7 @@ public final void execute() throws MojoExecutionException {
261261
for (FormatterFactory factory : formattersHolder.openFormatters.keySet()) {
262262
Formatter formatter = formattersHolder.openFormatters.get(factory);
263263
Iterable<File> files = formattersHolder.factoryToFiles.get(factory).get();
264-
process(formattersHolder.nameFor(factory), files, formatter, upToDateChecker, config);
264+
process(formattersHolder.nameFor(factory), files, formatter, upToDateChecker, getLintSuppressions());
265265
}
266266
} catch (PluginException e) {
267267
throw e.asMojoExecutionException();

plugin-maven/src/main/java/com/diffplug/spotless/maven/SpotlessApplyMojo.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.List;
2121

2222
import com.diffplug.spotless.LintState;
23+
import com.diffplug.spotless.LintSuppression;
2324

2425
import org.apache.maven.plugin.MojoExecutionException;
2526
import org.apache.maven.plugins.annotations.Mojo;
@@ -45,7 +46,7 @@ public class SpotlessApplyMojo extends AbstractSpotlessMojo {
4546
private boolean spotlessIdeHookUseStdOut;
4647

4748
@Override
48-
protected void process(String name, Iterable<File> files, Formatter formatter, UpToDateChecker upToDateChecker, FormatterConfig config) throws MojoExecutionException {
49+
protected void process(String name, Iterable<File> files, Formatter formatter, UpToDateChecker upToDateChecker, List<LintSuppression> lintSuppressions) throws MojoExecutionException {
4950
if (isIdeHook()) {
5051
IdeHook.performHook(files, formatter, spotlessIdeHook, spotlessIdeHookUseStdIn, spotlessIdeHookUseStdOut);
5152
return;
@@ -68,7 +69,7 @@ protected void process(String name, Iterable<File> files, Formatter formatter, U
6869
// File is not within baseDir, use absolute path as fallback
6970
relativePath = file.getAbsolutePath();
7071
}
71-
LintState lintState = LintState.of(formatter, file).withRemovedSuppressions(formatter, relativePath, config.getLintSuppressions());
72+
LintState lintState = LintState.of(formatter, file).withRemovedSuppressions(formatter, relativePath, lintSuppressions);
7273
boolean hasDirtyState = !lintState.getDirtyState().isClean() && !lintState.getDirtyState().didNotConverge();
7374
boolean hasUnsuppressedLints = lintState.isHasLints();
7475

plugin-maven/src/main/java/com/diffplug/spotless/maven/SpotlessCheckMojo.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.Map;
2323

2424
import com.diffplug.spotless.LintState;
25+
import com.diffplug.spotless.LintSuppression;
2526

2627
import org.apache.maven.plugin.MojoExecutionException;
2728
import org.apache.maven.plugins.annotations.LifecyclePhase;
@@ -66,7 +67,7 @@ public int getSeverity() {
6667
private MessageSeverity m2eIncrementalBuildMessageSeverity;
6768

6869
@Override
69-
protected void process(String name, Iterable<File> files, Formatter formatter, UpToDateChecker upToDateChecker, FormatterConfig config) throws MojoExecutionException {
70+
protected void process(String name, Iterable<File> files, Formatter formatter, UpToDateChecker upToDateChecker, List<LintSuppression> lintSuppressions) throws MojoExecutionException {
7071
ImpactedFilesTracker counter = new ImpactedFilesTracker();
7172

7273
List<File> problemFiles = new ArrayList<>();
@@ -86,7 +87,7 @@ protected void process(String name, Iterable<File> files, Formatter formatter, U
8687
// File is not within baseDir, use absolute path as fallback
8788
relativePath = file.getAbsolutePath();
8889
}
89-
LintState lintState = LintState.of(formatter, file).withRemovedSuppressions(formatter, relativePath, config.getLintSuppressions());
90+
LintState lintState = LintState.of(formatter, file).withRemovedSuppressions(formatter, relativePath, lintSuppressions);
9091
boolean hasDirtyState = !lintState.getDirtyState().isClean() && !lintState.getDirtyState().didNotConverge();
9192
boolean hasUnsuppressedLints = lintState.isHasLints();
9293

0 commit comments

Comments
 (0)