Skip to content

Commit e5a3167

Browse files
committed
Move ktlint version check closer to actual version use
1 parent 13a36fc commit e5a3167

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ public KtlintFormatterFunc(String version, boolean isScript, FileSignature edito
4444
// Experimental ruleset was replaced by implementing `Rule.Experimental` and checking the `ktlint_experimental` `.editorconfig` property
4545
// `RuleId` and `RuleSetId` became inline classes (mangled to be unrepresentable in Java source code, so reflection is needed), tracked here: https://github.com/pinterest/ktlint/issues/2041
4646
this.adapter = new KtLintCompat0Dot49Dot0Adapter();
47-
} else {
47+
} else if (minorVersion == 48) {
4848
// ExperimentalParams lost two constructor arguments, EditorConfigProperty moved to its own class
4949
this.adapter = new KtLintCompat0Dot48Dot0Adapter();
50+
} else {
51+
throw new IllegalStateException("Ktlint versions < 0.48.0 not supported!");
5052
}
5153
this.editorConfigPath = editorConfigPath;
5254
this.editorConfigOverrideMap = editorConfigOverrideMap;

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@ static final class State implements Serializable {
107107
@Nullable FileSignature editorConfigPath,
108108
Map<String, String> userData,
109109
Map<String, Object> editorConfigOverride) throws IOException {
110-
if (BadSemver.version(version) < BadSemver.version(0, 46, 0)) {
111-
throw new IllegalStateException("KtLint versions < 0.46.0 not supported!");
112-
}
113110
this.version = version;
114111
this.userData = new TreeMap<>(userData);
115112
this.editorConfigOverride = new TreeMap<>(editorConfigOverride);

0 commit comments

Comments
 (0)