Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using editorConfigOverride in kotlinGradle ktlint removes its default values, changing behavior #2226

Open
scscgit opened this issue Aug 17, 2024 · 0 comments

Comments

@scscgit
Copy link

scscgit commented Aug 17, 2024

When you use editorConfigOverride with map that has at least 1 entry, for example with arbitrary key that doesn't exist:

spotless {
    kotlinGradle {
        target("*.gradle.kts")
        ktlint("1.3.1").editorConfigOverride(
            mapOf(
                "abc" to "abc",
            ),
        )
    }
}

the default behavior changes. For example, when I fail the no-consecutive-comments rule by having this in build.gradle.kts:

/** Deps */
// Dep1

after adding the map with 1 element, ./gradlew spotlessApply will no longer display the error, and will successfully format the file.

> Task :spotlessApply

BUILD SUCCESSFUL in 220ms
6 actionable tasks: 3 executed, 3 up-to-date
15:25:53: Execution finished 'spotlessApply'.

With empty map, it finishes with error:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':spotlessKotlinGradle'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:130)
...
Caused by: java.lang.AssertionError: Error on line: 20, column: 5
rule: standard:no-consecutive-comments
an EOL comment may not be preceded by a KDoc. Reversed order is allowed though when separated by a newline.
        at com.diffplug.spotless.glue.ktlint.compat.KtLintCompatReporting.report(KtLintCompatReporting.java:23)
        at com.diffplug.spotless.glue.ktlint.compat.KtLintCompat1Dot0Dot0Adapter$FormatterCallback.invoke(KtLintCompat1Dot0Dot0Adapter.java:77)
        at com.diffplug.spotless.glue.ktlint.compat.KtLintCompat1Dot0Dot0Adapter$FormatterCallback.invoke(KtLintCompat1Dot0Dot0Adapter.java:72)
        at com.pinterest.ktlint.rule.engine.internal.CodeFormatter.format(CodeFormatter.kt:31)
        at com.pinterest.ktlint.rule.engine.api.KtLintRuleEngine.format(KtLintRuleEngine.kt:116)
...

Versions:
Gradle 8.9
id("com.diffplug.spotless") version "7.0.0.BETA1"
Windows 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants