Skip to content

Commit

Permalink
add tests to prove fix for #627 (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
wakingrufus authored Feb 9, 2023
1 parent 2e30850 commit 5d93f72
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,38 @@ 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 if (SemVer.parse(ktLintVersion) >= SemVer.parse("0.47.0")) {
// disabled rules property renamed in 0.47 (disabled_rules is still honored, but will print a warning)
editorConfig.appendText(
"""
root = true
[*.kt]
ktlint_disabled_rules = final-newline
""".trimIndent()
)
} else {
editorConfig.appendText(
"""
root = true
[*.kt]
disabled_rules = final-newline
""".trimIndent()
)
}
//language=Groovy
buildGradle.appendText(
"""
Expand All @@ -89,6 +110,7 @@ class DisabledRulesTest : AbstractPluginTest() {
build(CHECK_PARENT_TASK_NAME) {
assertThat(task(":$mainSourceSetCheckTaskName")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
assertThat(output).doesNotContain("Property 'ktlint_disabled_rules' is deprecated")
assertThat(output).doesNotContain("Property 'disabled_rules' is deprecated")
}
}
}
Expand Down

0 comments on commit 5d93f72

Please sign in to comment.