-
Notifications
You must be signed in to change notification settings - Fork 506
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
Wrong indentation for lambdas with many parameters #2816
Comments
You're right that this contradicts the Kotlin style guide. Reasoning is that when the parameters and arrows are on the same line, the distinction between parameters and body becomes blurry.
|
I see, thanks for the fast reply! Do you think that you could add a flag to toggle that behavior? I strongly prefer the official way and always add a blank line after the parameter list. |
My default reply to toggles is: https://pinterest.github.io/ktlint/latest/faq/#can-a-new-toggle-be-added-to-optionally-enabledisable-format-code-in-a-particular-way This case however is non-standard as the default behavior is not compliant with code style. But, if implemented, the default for |
Ok, I see. That sounds like a reasonable way to go as far as I understand it. With that I could still switch it like with other flags to both options, independent of the selected code style, right? Then I would definitely support that idea. |
It should just be the other way around. The current formatting complies with the default formatting of Intellij IDEA. For code styles
I will not introduce a new configurable toggle for this, but enforce it based on the code style. |
…al for code style `ktlint_official` For other code styles the indentation does not comply with Kotlin Coding conventions as other the formatting would conflict with default IDEA formatting. Closes #2816
The parameter list of a multiline lambda does not have the correct indentation. The corresponding unit test seems to do it wrong on purpose: https://github.com/pinterest/ktlint/blob/master/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/IndentationRuleTest.kt#L2607
Expected Behavior
Consider the last code block from https://kotlinlang.org/docs/coding-conventions.html#lambdas:
The lambda parameters have the same indentation as the arrow and the following statement.
Observed Behavior
When turning on the
Wrapping
rule withautoCorrect
enabled via detekt, the code is formatted like this:Steps to Reproduce
Enable the
Wrapping
rule and let the check run for the following code:Your Environment
./gradlew detekt --auto-correct
The text was updated successfully, but these errors were encountered: