Skip to content

ktlint - ktlint_code_style gets unconditionally overridden to its default value when not defined in editorConfigOverride #2142

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

Closed
OlivierGenez opened this issue May 28, 2024 · 0 comments · Fixed by #2143

Comments

@OlivierGenez
Copy link
Contributor

Bug report

Summary

ktlint_code_style gets unconditionally overridden to its default value (intellij_idea) when the editorConfigOverride map is non-empty but does not define it. As a result, it gets overridden even if it's actually
defined in the .editorconfig file.

For example, the following set up will result in ktlint_code_style being set to intellij_idea, although you would expect it to be set to ktlint_official as defined in .editorconfig:

  • .editorconfig:
ktlint_code_style = ktlint_official

# other properties
# ...
  • build.gradle
plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.6.21'
    id 'com.diffplug.spotless'
}

repositories { mavenCentral() }

spotless {
    kotlin {
        ktlint().editorConfigOverride([
            ktlint_test_key: true,
        ])
    }
}

Additional info

  • Gradle version: 8.0.2
  • Spotless version: 6.25.0
  • Operating system: macOS Sonoma 14.5
OlivierGenez added a commit to OlivierGenez/spotless that referenced this issue May 28, 2024
ktlint_code_style gets unconditionally overridden to its default value
(intellij_idea) when the editorConfigOverride map is non-empty but does
not define it. As a result, it gets overridden even if it's actually
defined in the .editorconfig file.

This change checks if ktlint_code_style is already defined in
.editorconfig before overriding it to its default value.

Fixes diffplug#2142.
OlivierGenez added a commit to OlivierGenez/spotless that referenced this issue May 28, 2024
ktlint_code_style gets unconditionally overridden to its default value
(intellij_idea) when the editorConfigOverride map is non-empty but does
not define it. As a result, it gets overridden even if it's actually
defined in the .editorconfig file.

This change checks if ktlint_code_style is already defined in
.editorconfig before overriding it to its default value.

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

Successfully merging a pull request may close this issue.

1 participant