From 267a3021f6587f42735b3080f4f77402d13af5c3 Mon Sep 17 00:00:00 2001 From: wakingrufus Date: Thu, 9 Feb 2023 09:30:31 -0600 Subject: [PATCH] add tests to prove fix for #627 --- CHANGELOG.md | 1 + .../gradle/ktlint/DisabledRulesTest.kt | 32 +++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fee82eaa..de2b5d0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/). - Fixed ktlint API compatibility issue around baselines in 0.46 and 0.47+ - Fixed disabled_rules warning when using new editorconfig syntax in ktlint 0.48+ [#625](https://github.com/JLLeitschuh/ktlint-gradle/pull/625) +- Fixed disabled_rules set only in editorconfig in ktlint 0.46+ [#628](https://github.com/JLLeitschuh/ktlint-gradle/pull/628) ## [11.1.0] - 2023-01-27 diff --git a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/DisabledRulesTest.kt b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/DisabledRulesTest.kt index 1afe0dd4..b7452747 100644 --- a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/DisabledRulesTest.kt +++ b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/DisabledRulesTest.kt @@ -63,17 +63,29 @@ class DisabledRulesTest : AbstractPluginTest() { @ParameterizedTest(name = "{0} with KtLint {1}: {displayName}") @ArgumentsSource(KtLintSupportedVersionsTest.SupportedKtlintVersionsProvider::class) fun lintDisabledRuleFinalNewlineEditorconfig(gradleVersion: GradleVersion, ktLintVersion: String) { - if (SemVer.parse(ktLintVersion) >= SemVer.parse("0.48.0")) { - // new way of disabling rules introduced in 0.48 + if (SemVer.parse(ktLintVersion) >= SemVer.parse("0.34.2")) { + // Rules disabling is supported since 0.34.2 ktlint version project(gradleVersion) { - editorConfig.appendText( - """ - root = true - - [*.kt] - ktlint_standard_final-newline = disabled - """.trimIndent() - ) + if (SemVer.parse(ktLintVersion) >= SemVer.parse("0.48.0")) { + // new way of disabling rules introduced in 0.48 + editorConfig.appendText( + """ + root = true + + [*.kt] + ktlint_standard_final-newline = disabled + """.trimIndent() + ) + } else { + editorConfig.appendText( + """ + root = true + + [*.kt] + disabled_rules = final-newline + """.trimIndent() + ) + } //language=Groovy buildGradle.appendText( """