From 707e50edb0a5d54d9634d28acfa403b209d57740 Mon Sep 17 00:00:00 2001 From: Bruno Medeiros Date: Wed, 19 Oct 2022 23:12:34 +0800 Subject: [PATCH 1/3] fix(ktlint): support ktlint_disabled_rules in 0.47+ --- .../glue/ktlint/compat/KtLintCompat0Dot47Dot0Adapter.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/compatKtLint0Dot47Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot47Dot0Adapter.java b/lib/src/compatKtLint0Dot47Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot47Dot0Adapter.java index 842294a5cc..66274fd0ef 100644 --- a/lib/src/compatKtLint0Dot47Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot47Dot0Adapter.java +++ b/lib/src/compatKtLint0Dot47Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot47Dot0Adapter.java @@ -100,9 +100,13 @@ private static EditorConfigOverride createEditorConfigOverride(final List .filter(rule -> rule instanceof UsesEditorConfigProperties) .flatMap(rule -> ((UsesEditorConfigProperties) rule).getEditorConfigProperties().stream()); + // get complete list of supported properties in DefaultEditorConfigProperties.INSTANCE + List> editorConfigProperties = DefaultEditorConfigProperties.INSTANCE.getEditorConfigProperties(); + editorConfigProperties.add(DefaultEditorConfigProperties.INSTANCE.getKtlintDisabledRulesProperty()); + // Create a mapping of properties to their names based on rule properties and default properties Map> supportedProperties = Stream - .concat(ruleProperties, DefaultEditorConfigProperties.INSTANCE.getEditorConfigProperties().stream()) + .concat(ruleProperties, editorConfigProperties.stream()) .distinct() .collect(Collectors.toMap(property -> property.getType().getName(), property -> property)); From 6824821bcd072a0a35370a2dc4604d8635fe35c9 Mon Sep 17 00:00:00 2001 From: Bruno Medeiros Date: Fri, 21 Oct 2022 10:14:38 +0800 Subject: [PATCH 2/3] user mutable list implementation before adding element --- .../glue/ktlint/compat/KtLintCompat0Dot47Dot0Adapter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/compatKtLint0Dot47Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot47Dot0Adapter.java b/lib/src/compatKtLint0Dot47Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot47Dot0Adapter.java index 66274fd0ef..757ffc922b 100644 --- a/lib/src/compatKtLint0Dot47Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot47Dot0Adapter.java +++ b/lib/src/compatKtLint0Dot47Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot47Dot0Adapter.java @@ -17,6 +17,7 @@ import static java.util.Collections.emptySet; +import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -101,7 +102,7 @@ private static EditorConfigOverride createEditorConfigOverride(final List .flatMap(rule -> ((UsesEditorConfigProperties) rule).getEditorConfigProperties().stream()); // get complete list of supported properties in DefaultEditorConfigProperties.INSTANCE - List> editorConfigProperties = DefaultEditorConfigProperties.INSTANCE.getEditorConfigProperties(); + List> editorConfigProperties = new ArrayList<>(DefaultEditorConfigProperties.INSTANCE.getEditorConfigProperties()); editorConfigProperties.add(DefaultEditorConfigProperties.INSTANCE.getKtlintDisabledRulesProperty()); // Create a mapping of properties to their names based on rule properties and default properties From fb3f658631df27bd98cf5bb0a54dae13be4b9818 Mon Sep 17 00:00:00 2001 From: Bruno Medeiros Date: Fri, 21 Oct 2022 10:15:04 +0800 Subject: [PATCH 3/3] add change log entries --- CHANGES.md | 1 + plugin-gradle/CHANGES.md | 1 + plugin-maven/CHANGES.md | 1 + 3 files changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index dc0bd38c60..f6671d2191 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ## [Unreleased] ### Fixed * Don't treat `@Value` as a type annotation [#1367](https://github.com/diffplug/spotless/pull/1367) +* Support `ktlint_disabled_rules` in `ktlint` 0.47.x [#1378](https://github.com/diffplug/spotless/pull/1378) ## [2.30.0] - 2022-09-14 ### Added diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md index a8adac938d..5acd85ddc8 100644 --- a/plugin-gradle/CHANGES.md +++ b/plugin-gradle/CHANGES.md @@ -5,6 +5,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ## [Unreleased] ### Fixed * Don't treat `@Value` as a type annotation [#1367](https://github.com/diffplug/spotless/pull/1367) +* Support `ktlint_disabled_rules` in `ktlint` 0.47.x [#1378](https://github.com/diffplug/spotless/pull/1378) ## [6.11.0] - 2022-09-14 ### Added diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index 75659026d4..b08a2366fd 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -5,6 +5,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ## [Unreleased] ### Fixed * Don't treat `@Value` as a type annotation [#1367](https://github.com/diffplug/spotless/pull/1367) +* Support `ktlint_disabled_rules` in `ktlint` 0.47.x [#1378](https://github.com/diffplug/spotless/pull/1378) ## [2.27.2] - 2022-10-10 ### Fixed