Skip to content

Commit 1c7dd53

Browse files
committed
Remove unused isScript param in Ktlint format step
1 parent a0936e1 commit 1c7dd53

File tree

13 files changed

+15
-34
lines changed

13 files changed

+15
-34
lines changed

lib/src/compatKtLint0Dot48Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot48Dot0Adapter.java

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ public Unit invoke(LintError lint, Boolean corrected) {
7676
public String format(
7777
String text,
7878
Path path,
79-
boolean isScript,
8079
Path editorConfigPath,
8180
Map<String, Object> editorConfigOverrideMap) {
8281
final FormatterCallback formatterCallback = new FormatterCallback();

lib/src/compatKtLint0Dot49Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot49Dot0Adapter.java

-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ public Unit invoke(LintError lint, Boolean corrected) {
122122
public String format(
123123
String text,
124124
Path path,
125-
boolean isScript,
126125
Path editorConfigPath,
127126
Map<String, Object> editorConfigOverrideMap) {
128127
final FormatterCallback formatterCallback = new FormatterCallback();

lib/src/compatKtLint0Dot50Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot50Dot0Adapter.java

-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ public Unit invoke(LintError lint, Boolean corrected) {
8585
public String format(
8686
String text,
8787
Path path,
88-
boolean isScript,
8988
Path editorConfigPath,
9089
Map<String, Object> editorConfigOverrideMap) {
9190
final FormatterCallback formatterCallback = new FormatterCallback();

lib/src/compatKtLint1Dot0Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat1Dot0Dot0Adapter.java

-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ public Unit invoke(LintError lint, Boolean corrected) {
8585
public String format(
8686
String text,
8787
Path path,
88-
boolean isScript,
8988
Path editorConfigPath,
9089
Map<String, Object> editorConfigOverrideMap) {
9190
final FormatterCallback formatterCallback = new FormatterCallback();

lib/src/compatKtLintApi/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompatAdapter.java

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public interface KtLintCompatAdapter {
2323
String format(
2424
String text,
2525
Path path,
26-
boolean isScript,
2726
Path editorConfigPath,
2827
Map<String, Object> editorConfigOverrideMap);
2928
}

lib/src/ktlint/java/com/diffplug/spotless/glue/ktlint/KtlintFormatterFunc.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@
2525

2626
public class KtlintFormatterFunc implements FormatterFunc.NeedsFile {
2727

28-
private final boolean isScript;
2928
private final KtLintCompatAdapter adapter;
3029
private final FileSignature editorConfigPath;
3130
private final Map<String, Object> editorConfigOverrideMap;
3231

33-
public KtlintFormatterFunc(String version, boolean isScript, FileSignature editorConfigPath,
32+
public KtlintFormatterFunc(String version, FileSignature editorConfigPath,
3433
Map<String, Object> editorConfigOverrideMap) {
3534
String[] versions = version.split("\\.");
3635
int majorVersion = Integer.parseInt(versions[0]);
@@ -57,7 +56,6 @@ public KtlintFormatterFunc(String version, boolean isScript, FileSignature edito
5756
}
5857
this.editorConfigPath = editorConfigPath;
5958
this.editorConfigOverrideMap = editorConfigOverrideMap;
60-
this.isScript = isScript;
6159
}
6260

6361
@Override
@@ -67,6 +65,6 @@ public String applyWithFile(String unix, File file) {
6765
if (editorConfigPath != null) {
6866
absoluteEditorConfigPath = editorConfigPath.getOnlyFile().toPath();
6967
}
70-
return adapter.format(unix, file.toPath(), isScript, absoluteEditorConfigPath, editorConfigOverrideMap);
68+
return adapter.format(unix, file.toPath(), absoluteEditorConfigPath, editorConfigOverrideMap);
7169
}
7270
}

lib/src/main/java/com/diffplug/spotless/kotlin/KtLintStep.java

+4-15
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,17 @@ public static FormatterStep create(Provisioner provisioner) {
4646
}
4747

4848
public static FormatterStep create(String version, Provisioner provisioner) {
49-
return create(version, provisioner, Collections.emptyMap());
50-
}
51-
52-
public static FormatterStep create(String version, Provisioner provisioner,
53-
Map<String, Object> editorConfigOverride) {
54-
return create(version, provisioner, false, null, editorConfigOverride);
49+
return create(version, provisioner, null, Collections.emptyMap());
5550
}
5651

5752
public static FormatterStep create(String version,
5853
Provisioner provisioner,
59-
boolean isScript,
6054
@Nullable FileSignature editorConfig,
6155
Map<String, Object> editorConfigOverride) {
6256
Objects.requireNonNull(version, "version");
6357
Objects.requireNonNull(provisioner, "provisioner");
6458
return FormatterStep.createLazy(NAME,
65-
() -> new State(version, provisioner, isScript, editorConfig, editorConfigOverride),
59+
() -> new State(version, provisioner, editorConfig, editorConfigOverride),
6660
State::createFormat);
6761
}
6862

@@ -72,9 +66,6 @@ public static String defaultVersion() {
7266

7367
static final class State implements Serializable {
7468
private static final long serialVersionUID = 1L;
75-
76-
/** Are the files being linted Kotlin script files. */
77-
private final boolean isScript;
7869
/** The jar that contains the formatter. */
7970
final JarState jarState;
8071
private final TreeMap<String, Object> editorConfigOverride;
@@ -84,23 +75,21 @@ static final class State implements Serializable {
8475

8576
State(String version,
8677
Provisioner provisioner,
87-
boolean isScript,
8878
@Nullable FileSignature editorConfigPath,
8979
Map<String, Object> editorConfigOverride) throws IOException {
9080
this.version = version;
9181
this.editorConfigOverride = new TreeMap<>(editorConfigOverride);
9282
this.jarState = JarState.from((version.startsWith("0.") ? MAVEN_COORDINATE_0_DOT : MAVEN_COORDINATE_1_DOT) + version,
9383
provisioner);
9484
this.editorConfigPath = editorConfigPath;
95-
this.isScript = isScript;
9685
}
9786

9887
FormatterFunc createFormat() throws Exception {
9988
final ClassLoader classLoader = jarState.getClassLoader();
10089
Class<?> formatterFunc = classLoader.loadClass("com.diffplug.spotless.glue.ktlint.KtlintFormatterFunc");
10190
Constructor<?> constructor = formatterFunc.getConstructor(
102-
String.class, boolean.class, FileSignature.class, Map.class);
103-
return (FormatterFunc.NeedsFile) constructor.newInstance(version, isScript, editorConfigPath, editorConfigOverride);
91+
String.class, FileSignature.class, Map.class);
92+
return (FormatterFunc.NeedsFile) constructor.newInstance(version, editorConfigPath, editorConfigOverride);
10493
}
10594
}
10695
}

lib/src/testCompatKtLint0Dot48Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot48Dot0AdapterTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void testDefaults(@TempDir Path path) throws IOException {
3838

3939
Map<String, Object> editorConfigOverrideMap = new HashMap<>();
4040

41-
String formatted = ktLintCompat0Dot48Dot0Adapter.format(text, filePath, false, null, editorConfigOverrideMap);
41+
String formatted = ktLintCompat0Dot48Dot0Adapter.format(text, filePath, null, editorConfigOverrideMap);
4242
assertEquals("class empty_class_body\n", formatted);
4343
}
4444

@@ -54,7 +54,7 @@ public void testEditorConfigCanDisable(@TempDir Path path) throws IOException {
5454
// ktlint_filename is an invalid rule in ktlint 0.48.0
5555
editorConfigOverrideMap.put("ktlint_filename", "disabled");
5656

57-
String formatted = ktLintCompat0Dot48Dot0Adapter.format(text, filePath, false, null, editorConfigOverrideMap);
57+
String formatted = ktLintCompat0Dot48Dot0Adapter.format(text, filePath, null, editorConfigOverrideMap);
5858
assertEquals("class fails_no_semicolons {\n\tval i = 0;\n}\n", formatted);
5959
}
6060

lib/src/testCompatKtLint0Dot49Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot49Dot0AdapterTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void testDefaults(@TempDir Path path) throws IOException {
3838

3939
Map<String, Object> editorConfigOverrideMap = new HashMap<>();
4040

41-
String formatted = ktLintCompat0Dot49Dot0Adapter.format(text, filePath, false, null, editorConfigOverrideMap);
41+
String formatted = ktLintCompat0Dot49Dot0Adapter.format(text, filePath, null, editorConfigOverrideMap);
4242
assertEquals("class EmptyClassBody\n", formatted);
4343
}
4444

@@ -52,7 +52,7 @@ public void testEditorConfigCanDisable(@TempDir Path path) throws IOException {
5252
editorConfigOverrideMap.put("indent_style", "tab");
5353
editorConfigOverrideMap.put("ktlint_standard_no-semi", "disabled");
5454

55-
String formatted = ktLintCompat0Dot49Dot0Adapter.format(text, filePath, false, null, editorConfigOverrideMap);
55+
String formatted = ktLintCompat0Dot49Dot0Adapter.format(text, filePath, null, editorConfigOverrideMap);
5656
assertEquals("class FailsNoSemicolons {\n\tval i = 0;\n}\n", formatted);
5757
}
5858

lib/src/testCompatKtLint0Dot50Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot50Dot0AdapterTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void testDefaults(@TempDir Path path) throws IOException {
3838

3939
Map<String, Object> editorConfigOverrideMap = new HashMap<>();
4040

41-
String formatted = KtLintCompat0Dot50Dot0Adapter.format(text, filePath, false, null, editorConfigOverrideMap);
41+
String formatted = KtLintCompat0Dot50Dot0Adapter.format(text, filePath, null, editorConfigOverrideMap);
4242
assertEquals("class EmptyClassBody\n", formatted);
4343
}
4444

@@ -52,7 +52,7 @@ public void testEditorConfigCanDisable(@TempDir Path path) throws IOException {
5252
editorConfigOverrideMap.put("indent_style", "tab");
5353
editorConfigOverrideMap.put("ktlint_standard_no-semi", "disabled");
5454

55-
String formatted = KtLintCompat0Dot50Dot0Adapter.format(text, filePath, false, null, editorConfigOverrideMap);
55+
String formatted = KtLintCompat0Dot50Dot0Adapter.format(text, filePath, null, editorConfigOverrideMap);
5656
assertEquals("class FailsNoSemicolons {\n\tval i = 0;\n}\n", formatted);
5757
}
5858

lib/src/testCompatKtLint1Dot0Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat1Dot0Dot0AdapterTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void testDefaults(@TempDir Path path) throws IOException {
3838

3939
Map<String, Object> editorConfigOverrideMap = new HashMap<>();
4040

41-
String formatted = KtLintCompat1Dot0Dot0Adapter.format(text, filePath, false, null, editorConfigOverrideMap);
41+
String formatted = KtLintCompat1Dot0Dot0Adapter.format(text, filePath, null, editorConfigOverrideMap);
4242
assertEquals("class EmptyClassBody\n", formatted);
4343
}
4444

@@ -52,7 +52,7 @@ public void testEditorConfigCanDisable(@TempDir Path path) throws IOException {
5252
editorConfigOverrideMap.put("indent_style", "tab");
5353
editorConfigOverrideMap.put("ktlint_standard_no-semi", "disabled");
5454

55-
String formatted = KtLintCompat1Dot0Dot0Adapter.format(text, filePath, false, null, editorConfigOverrideMap);
55+
String formatted = KtLintCompat1Dot0Dot0Adapter.format(text, filePath, null, editorConfigOverrideMap);
5656
assertEquals("class FailsNoSemicolons {\n\tval i = 0;\n}\n", formatted);
5757
}
5858

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

-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ private FormatterStep createStep() {
186186
return KtLintStep.create(
187187
version,
188188
provisioner(),
189-
isScript(),
190189
editorConfigPath,
191190
editorConfigOverride);
192191
}

plugin-maven/src/main/java/com/diffplug/spotless/maven/kotlin/Ktlint.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ public FormatterStep newFormatterStep(final FormatterStepConfig stepConfig) {
4747
editorConfigOverride = new HashMap<>();
4848
}
4949

50-
return KtLintStep.create(ktlintVersion, stepConfig.getProvisioner(), false, configPath, editorConfigOverride);
50+
return KtLintStep.create(ktlintVersion, stepConfig.getProvisioner(), configPath, editorConfigOverride);
5151
}
5252
}

0 commit comments

Comments
 (0)