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

Trailing comma defaults changed in 0.48 #1810

Closed
Spikhalskiy opened this issue Feb 6, 2023 · 3 comments · Fixed by #1814
Closed

Trailing comma defaults changed in 0.48 #1810

Spikhalskiy opened this issue Feb 6, 2023 · 3 comments · Fixed by #1814

Comments

@Spikhalskiy
Copy link

Spikhalskiy commented Feb 6, 2023

Expected Behavior

With the default ruleset ktlint shouldn't add trailing commas on the call and declaration sites.
It's the behavior with 0.47
It's the specified behavior in the doc:
https://pinterest.github.io/ktlint/rules/configuration-ktlint/#trailing-comma-on-declaration-site
https://pinterest.github.io/ktlint/rules/configuration-ktlint/#trailing-comma-on-call-site

Observed Behavior

After upgrading from 0.47.x to 0.48.{0,1,2}, applying ktint reformatted code to add trailing to declaration sites.
To preserve an old behavior I had to add

# ij_kotlin_allow_trailing_comma = false
# ij_kotlin_allow_trailing_comma_on_call_site = false

to '.editorconfig' while it shouldn't be necessary, these values are stated as defaults.

Your Environment

  • Version of ktlint used: 0.47.1, 0.48.{0,1,2}

  • Relevant parts of the .editorconfig settings

    • 0.47.x:
    root = true
    
    [*.{kt,kts}]
    indent_size = 2
    
    • 0.48.{0,1,2} to save an old behavior:
    root = true
    
    [*.{kt,kts}]
    indent_size = 2
    
    ij_kotlin_allow_trailing_comma = false
    ij_kotlin_allow_trailing_comma_on_call_site = false
    
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): diffplug/spotless:6.14.1

  • Version of Gradle used (if applicable): 7.6

@paul-dingemans
Copy link
Collaborator

This change is documented in the release notes. Also see PR #1669

The default value for trailing comma's on declaration site is changed to true unless the android codestyle is enabled. Note that KtLint from a consistency viewpoint enforces the trailing comma on declaration site while default IntelliJ IDEA formatting only allows the trailing comma but leaves it up to the developer's discretion. (#1669)

@paul-dingemans paul-dingemans closed this as not planned Won't fix, can't repro, duplicate, stale Feb 6, 2023
@paul-dingemans paul-dingemans pinned this issue Feb 6, 2023
@Spikhalskiy
Copy link
Author

@paul-dingemans Thank you for the context! Should there be a follow-up update of the documentation on https://pinterest.github.io/ktlint/rules/configuration-ktlint?

@paul-dingemans
Copy link
Collaborator

@paul-dingemans Thank you for the context! Should there be a follow-up update of the documentation on https://pinterest.github.io/ktlint/rules/configuration-ktlint?

Yes good remark. To be fixed by #1814

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.

2 participants