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

[ktlint 0.37.0] New indentation rule issues #764

Closed
gotev opened this issue Jun 4, 2020 · 9 comments · Fixed by #1176
Closed

[ktlint 0.37.0] New indentation rule issues #764

gotev opened this issue Jun 4, 2020 · 9 comments · Fixed by #1176

Comments

@gotev
Copy link

gotev commented Jun 4, 2020

Expected Behavior

When I have statements like those:

myStatement(parameter1, parameter2, parameter3)

myOtherStatement(parameter1, lambda = {
    otherStatement
})

I expect the linter to report nothing

Observed Behavior

I get a bunch of:

Missing newline after "("
Missing newline after ","
Missing newline before ")"

Your Environment

  • Version of ktlint used: 0.37.0
  • Operating System and version: macOS Catalina 10.15.5

With ktlint up to 0.36.0 no problems. I believe it's something with the new indentation rule promoted from experimental. Is it possible to keep the "old" behaviour? I find it excessive to have very short statements split on multiple lines only for a ktlint rule.

@gotev gotev changed the title New indentation rile New indentation rule issues Jun 4, 2020
@gotev gotev changed the title New indentation rule issues [ktlint 0.37.0] New indentation rule issues Jun 4, 2020
@shashachu
Copy link
Contributor

Hi, yes the formerly-experimental-now-standard rule is more aggressive with inserting newlines, and I understand IDEA also accepts the formatting you've shown in the issue. We'll discuss internally whether any changes need to be made.

@Tapchicoma
Copy link
Collaborator

After some discussion we decided to split indentation rule into more granular rules, that could be disabled via .editorconfig. Default behaviour would be as observed one.

@douglaskazumi
Copy link

douglaskazumi commented Jun 19, 2020

@Tapchicoma what's the correct rule to be disabled in this case? Is it indent or is there any more specific rule I can disable?

For clarity here's an example (this is accepted by Android Studio auto-format):

                .subscribe({
                    doSomenthing()
                }, {
                    error()
                })

is formatted by the formatKotlin task into this:

                .subscribe(
                    {
                        doSomenthing()
                    },
                    {
                        error()
                    }
                )

Thanks

@romtsn
Copy link
Collaborator

romtsn commented Jun 19, 2020

Yes, it is the entire indent rule at the moment

@kim01jun
Copy link
Contributor

I think that indent rule is too comprehensive.
How about add specific rule aggressive-inserting-newlines to disable issue's example only?

@realdadfish
Copy link

Yes, please, this currently stops us from upgrading to 0.37 or later, otherwise we'd face thousands of lines of reformatting :(

@kharf
Copy link

kharf commented Jul 20, 2020

same here, we don't want the curly braces to be placed in new lines!

@maxirosson
Copy link

Any news about this?

@Tapchicoma Tapchicoma removed this from the 0.40.0 milestone Dec 5, 2020
@firmwaves
Copy link

@Tapchicoma I'm guessing the 0.41.0 milestone is incorrect since it has been released? any other updates here?

Chris-V added a commit to kronostechnologies/standards that referenced this issue Aug 9, 2021
ktlint's indentation issue has also been fixed, allowing us to delete
our custom rule.

cc pinterest/ktlint#764
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants