Skip to content

Commit eeee68a

Browse files
committed
Minor renaming to condense SpotlessApplyMojo.
1 parent d7ff074 commit eeee68a

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,7 @@ public int getCleaned() {
5050
return nbCleaned;
5151
}
5252

53+
public int getTotal() {
54+
return nbskippedAsCleanCache + nbCheckedButAlreadyClean + nbCleaned;
55+
}
5356
}

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public class SpotlessApplyMojo extends AbstractSpotlessMojo {
3333

3434
@Override
3535
protected void process(Iterable<File> files, Formatter formatter, UpToDateChecker upToDateChecker) throws MojoExecutionException {
36-
ImpactedFilesTracker impactedFilesTracker = new ImpactedFilesTracker();
36+
ImpactedFilesTracker counter = new ImpactedFilesTracker();
3737

3838
for (File file : files) {
3939
if (upToDateChecker.isUpToDate(file.toPath())) {
40-
impactedFilesTracker.skippedAsCleanCache();
40+
counter.skippedAsCleanCache();
4141
if (getLog().isDebugEnabled()) {
4242
getLog().debug("Spotless will not format an up-to-date file: " + file);
4343
}
@@ -50,9 +50,9 @@ protected void process(Iterable<File> files, Formatter formatter, UpToDateChecke
5050
getLog().info(String.format("Writing clean file: %s", file));
5151
dirtyState.writeCanonicalTo(file);
5252
buildContext.refresh(file);
53-
impactedFilesTracker.cleaned();
53+
counter.cleaned();
5454
} else {
55-
impactedFilesTracker.checkedButAlreadyClean();
55+
counter.checkedButAlreadyClean();
5656
}
5757
} catch (IOException e) {
5858
throw new MojoExecutionException("Unable to format file " + file, e);
@@ -62,13 +62,9 @@ protected void process(Iterable<File> files, Formatter formatter, UpToDateChecke
6262
}
6363

6464
// We print the number of considered files which is useful when ratchetFrom is setup
65-
int skippedAsCleanCache = impactedFilesTracker.getSkippedAsCleanCache();
66-
int checkedButAlreadyClean = impactedFilesTracker.getCheckedButAlreadyClean();
67-
int cleaned = impactedFilesTracker.getCleaned();
68-
int totalProcessed = skippedAsCleanCache + checkedButAlreadyClean + cleaned;
69-
if (totalProcessed > 0) {
65+
if (counter.getTotal() > 0) {
7066
getLog().info(String.format("Spotless.%s is keeping %s files clean - %s were changed to be clean, %s were already clean, %s were skipped because caching determined they were already clean",
71-
formatter.getName(), totalProcessed, cleaned, checkedButAlreadyClean, skippedAsCleanCache));
67+
formatter.getName(), counter.getTotal(), counter.getCleaned(), counter.getCheckedButAlreadyClean(), counter.getSkippedAsCleanCache()));
7268
} else {
7369
getLog().warn(String.format("Spotless.%s has no target files. Examine your `<includes>`: https://github.com/diffplug/spotless/tree/main/plugin-maven#quickstart", formatter.getName()));
7470
}

0 commit comments

Comments
 (0)