Skip to content

Commit 7118f6a

Browse files
authored
Correctly provide EditorConfig property types for Ktlint (#2052 closes #1904)
2 parents f0e55ad + 337cf74 commit 7118f6a

File tree

7 files changed

+14
-8
lines changed

7 files changed

+14
-8
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
2424
* **BREAKING** Replace `PipeStepPair` with `FenceStep`. ([#1954](https://github.com/diffplug/spotless/pull/1954))
2525
### Fixed
2626
* Ignore system git config when running tests ([#1990](https://github.com/diffplug/spotless/issues/1990))
27+
* Correctly provide EditorConfig property types for Ktlint ([#2052](https://github.com/diffplug/spotless/issues/2052))
2728

2829
## [2.45.0] - 2024-01-23
2930
### Added

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 DiffPlug
2+
* Copyright 2023-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.
@@ -38,6 +38,7 @@
3838
import com.pinterest.ktlint.rule.engine.api.LintError;
3939
import com.pinterest.ktlint.rule.engine.core.api.Rule;
4040
import com.pinterest.ktlint.rule.engine.core.api.RuleProvider;
41+
import com.pinterest.ktlint.rule.engine.core.api.RuleProviderKt;
4142
import com.pinterest.ktlint.rule.engine.core.api.editorconfig.CodeStyleEditorConfigPropertyKt;
4243
import com.pinterest.ktlint.rule.engine.core.api.editorconfig.EditorConfigProperty;
4344
import com.pinterest.ktlint.rule.engine.core.api.editorconfig.EndOfLinePropertyKt;
@@ -142,7 +143,7 @@ public String format(
142143
if (editorConfigPath == null || !Files.exists(editorConfigPath)) {
143144
editorConfig = EditorConfigDefaults.Companion.getEMPTY_EDITOR_CONFIG_DEFAULTS();
144145
} else {
145-
editorConfig = EditorConfigDefaults.Companion.load(editorConfigPath);
146+
editorConfig = EditorConfigDefaults.Companion.load(editorConfigPath, RuleProviderKt.propertyTypes(allRuleProviders));
146147
}
147148

148149
return new KtLintRuleEngine(

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 DiffPlug
2+
* Copyright 2023-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.
@@ -17,7 +17,6 @@
1717

1818
import java.nio.file.Files;
1919
import java.nio.file.Path;
20-
import java.util.Collections;
2120
import java.util.List;
2221
import java.util.Map;
2322
import java.util.Objects;
@@ -38,6 +37,7 @@
3837
import com.pinterest.ktlint.rule.engine.core.api.Rule;
3938
import com.pinterest.ktlint.rule.engine.core.api.RuleId;
4039
import com.pinterest.ktlint.rule.engine.core.api.RuleProvider;
40+
import com.pinterest.ktlint.rule.engine.core.api.RuleProviderKt;
4141
import com.pinterest.ktlint.rule.engine.core.api.RuleSetId;
4242
import com.pinterest.ktlint.rule.engine.core.api.editorconfig.CodeStyleEditorConfigPropertyKt;
4343
import com.pinterest.ktlint.rule.engine.core.api.editorconfig.EditorConfigProperty;
@@ -105,7 +105,7 @@ public String format(
105105
if (editorConfigPath == null || !Files.exists(editorConfigPath)) {
106106
editorConfig = EditorConfigDefaults.Companion.getEMPTY_EDITOR_CONFIG_DEFAULTS();
107107
} else {
108-
editorConfig = EditorConfigDefaults.Companion.load(editorConfigPath, Collections.emptySet());
108+
editorConfig = EditorConfigDefaults.Companion.load(editorConfigPath, RuleProviderKt.propertyTypes(allRuleProviders));
109109
}
110110

111111
return new KtLintRuleEngine(

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 DiffPlug
2+
* Copyright 2023-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.
@@ -17,7 +17,6 @@
1717

1818
import java.nio.file.Files;
1919
import java.nio.file.Path;
20-
import java.util.Collections;
2120
import java.util.List;
2221
import java.util.Map;
2322
import java.util.Objects;
@@ -38,6 +37,7 @@
3837
import com.pinterest.ktlint.rule.engine.core.api.Rule;
3938
import com.pinterest.ktlint.rule.engine.core.api.RuleId;
4039
import com.pinterest.ktlint.rule.engine.core.api.RuleProvider;
40+
import com.pinterest.ktlint.rule.engine.core.api.RuleProviderKt;
4141
import com.pinterest.ktlint.rule.engine.core.api.RuleSetId;
4242
import com.pinterest.ktlint.rule.engine.core.api.editorconfig.CodeStyleEditorConfigPropertyKt;
4343
import com.pinterest.ktlint.rule.engine.core.api.editorconfig.EditorConfigProperty;
@@ -105,7 +105,7 @@ public String format(
105105
if (editorConfigPath == null || !Files.exists(editorConfigPath)) {
106106
editorConfig = EditorConfigDefaults.Companion.getEMPTY_EDITOR_CONFIG_DEFAULTS();
107107
} else {
108-
editorConfig = EditorConfigDefaults.Companion.load(editorConfigPath, Collections.emptySet());
108+
editorConfig = EditorConfigDefaults.Companion.load(editorConfigPath, RuleProviderKt.propertyTypes(allRuleProviders));
109109
}
110110

111111
return new KtLintRuleEngine(

plugin-gradle/CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
55
## [Unreleased]
66
### Fixed
77
* Ignore system git config when running tests ([#1990](https://github.com/diffplug/spotless/issues/1990))
8+
* Correctly provide EditorConfig property types for Ktlint ([#2052](https://github.com/diffplug/spotless/issues/2052))
89
* Fixed memory leak introduced in 6.21.0 ([#2067](https://github.com/diffplug/spotless/issues/2067))
910
### Changes
1011
* Bump default `ktfmt` version to latest `0.46` -> `0.47`. ([#2045](https://github.com/diffplug/spotless/pull/2045))

plugin-maven/CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
55
## [Unreleased]
66
### Fixed
77
* Ignore system git config when running tests ([#1990](https://github.com/diffplug/spotless/issues/1990))
8+
* Correctly provide EditorConfig property types for Ktlint ([#2052](https://github.com/diffplug/spotless/issues/2052))
89
### Changes
910
* Bump default `ktfmt` version to latest `0.46` -> `0.47`. ([#2045](https://github.com/diffplug/spotless/pull/2045))
1011
* Bump default `sortpom` version to latest `3.2.1` -> `3.4.0`. ([#2049](https://github.com/diffplug/spotless/pull/2049))

testlib/src/main/resources/kotlin/ktlint/ktlint_official/.editorconfig

+2
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ root = true
44
ij_kotlin_allow_trailing_comma = true
55
ij_kotlin_allow_trailing_comma_on_call_site = true
66
ktlint_code_style = ktlint_official
7+
# See https://github.com/diffplug/spotless/issues/1904.
8+
ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 2

0 commit comments

Comments
 (0)