Skip to content

Commit 154ca27

Browse files
committed
Simplify LicenseHeaderStep.
1 parent 7441bad commit 154ca27

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2023 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.
@@ -120,14 +120,12 @@ public LicenseHeaderStep withSkipLinesMatching(@Nullable String skipLinesMatchin
120120
}
121121

122122
public FormatterStep build() {
123-
FormatterStep formatterStep = null;
124-
123+
FormatterStep formatterStep;
125124
if (yearMode.get() == YearMode.SET_FROM_GIT) {
126-
formatterStep = FormatterStep.createNeverUpToDateLazy(name, () -> {
125+
formatterStep = FormatterStep.createLazy(name, () -> {
127126
boolean updateYear = false; // doesn't matter
128-
Runtime runtime = new Runtime(headerLazy.get(), delimiter, yearSeparator, updateYear, skipLinesMatching);
129-
return FormatterFunc.needsFile(runtime::setLicenseHeaderYearsFromGitHistory);
130-
});
127+
return new Runtime(headerLazy.get(), delimiter, yearSeparator, updateYear, skipLinesMatching);
128+
}, step -> FormatterFunc.needsFile(step::format));
131129
} else {
132130
formatterStep = FormatterStep.createLazy(name, () -> {
133131
// by default, we should update the year if the user is using ratchetFrom
@@ -146,11 +144,9 @@ public FormatterStep build() {
146144
return new Runtime(headerLazy.get(), delimiter, yearSeparator, updateYear, skipLinesMatching);
147145
}, step -> FormatterFunc.needsFile(step::format));
148146
}
149-
150147
if (contentPattern == null) {
151148
return formatterStep;
152149
}
153-
154150
return formatterStep.filterByContent(OnMatch.INCLUDE, contentPattern);
155151
}
156152

0 commit comments

Comments
 (0)