Using editorConfigOverride in kotlinGradle ktlint removes its default values, changing behavior
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- kotlin
- Domain
- build-system
Research direction
Start by reproducing the Gradle Kotlin DSL example with a nonempty editorConfigOverride map and compare it with the empty-map case. Then trace the editorConfigOverride entry point and existing ktlint configuration tests, if present. Done means default ktlint behavior, including no-consecutive-comments, remains enforced when an override contains unrelated keys.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Java
- Stars
- 5.7k
- Forks
- 560
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 43
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from diffplug/spotless
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 66/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
All issues in diffplug/spotless
Similar issues
-
certification
Difficulty 1/5 Under an hour Newbie friendliness 80/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
[BUG] ECR GetAuthorizationToken returns a proxyEndpoint for the default region, not the request's Openbug ecr
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Needs: Triage Type: Feature request
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
AntennaPod/AntennaPod#8794 ·
-
agentic-workflows
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
github/copilot-sdk#2760 ·