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

Continuation indent with Method declaration parameters #182

Closed
AllanHasegawa opened this issue Apr 1, 2018 · 6 comments
Closed

Continuation indent with Method declaration parameters #182

AllanHasegawa opened this issue Apr 1, 2018 · 6 comments

Comments

@AllanHasegawa
Copy link

Hey o/

Just started using this awesome project, and now I'm unsure about something.

By default, Android Studio will use continuation indent with "method declaration parameters".

When using an indent of 2 with a continuation of 4, this is how Android Studio formats this code:

object Bar {
.,data class Foo(
.,.,.,val value: String
.,)
}

However, when I run ktlint, it warns me that it expects the following indentation:

object Bar {
.,data class Foo(
.,.,val value: String
.,)
}

Is ktlint working as expected here? I'm in doubt because the README (in this section) doesn't tell us to disable the continuation indent for this case in Intellij.

Thank you :)

@shyiko
Copy link
Collaborator

shyiko commented Apr 2, 2018

Hi.

Use regular indent (4 spaces) for constructor parameters.
(per https://kotlinlang.org/docs/reference/coding-conventions.html#class-header-formatting)

My recommendation is to keep indent_size and continuation_indent_size equal (if .editorconfig contains indent_size=2 then continuation_indent_size=2 should be present too). This way you'll avoid some other issues.

I'll keep this ticket open until README is updated.

@ScottPierce
Copy link

@shyiko but jetbrains style guide has a continuation indent.

Kotlin/kotlin-style-guide#38
Quoting Yole:

In our style guide, the continuation indent is still 8, but many places which previously used continuation indent have now been switched to normal indent.

Also, our style guide does not have any line length limit.

My team is encountering this issue as well.

@exsilium
Copy link

One more vote that we are hitting this issue. In my mind, if .editorconfig specifies different indentation size for continuation_indent_size, that should be honored in parameter listing as continuation indent. Any hopes that this will be fixed in ktlint?

@shyiko
Copy link
Collaborator

shyiko commented Apr 17, 2018

@exsilium continuation_indent_size is not used for parameters per android/kotlin-guides#37, as such it's unlikely to change. As an option, though, if you change indent_size to unset indentation check will be suppressed (i.e. ktlint will accept any indentation).

@exsilium
Copy link

Hi @shyiko. Altough i'm saddened to hear that but I thank you for your answer. Cheers! 🍻 🙇

@shyiko
Copy link
Collaborator

shyiko commented Apr 22, 2018

README updated.

@shyiko shyiko closed this as completed Apr 22, 2018
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

No branches or pull requests

4 participants