-
Notifications
You must be signed in to change notification settings - Fork 741
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
Install ktlint plugin #3957
Install ktlint plugin #3957
Conversation
Try running |
08a54c9
to
09710d8
Compare
There is still a problem, Android Studio does not always order imports correctly :/ |
I think that the import ordering issues have been discussed extensively on the ktlint repo. Note that various settings can affect the import ordering, e.g. Android Studio settings for the Kotlin language and for the project. I can't check right now, but there might be a ktlint setting that tells ktlint that the project uses IntelliJ / AS. Ktlint then knows that the import ordering should use different rules. |
…import-ordering"
09710d8
to
d1e9f31
Compare
Thanks @erikhuizinga . I've force push the branch with latest improvement. |
So the ktlint plugin is now working as expected. The following rule are now enabled (were disabled before):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to keep && and || formating as it is currently
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for this 💯
some of the line breaks for closing fun parameters/constructors etc are a little strange with
class Foo(val prop: Long) :
RealmObject() {
}
but they should be easy enough to fix later on with a find replace/regex
would have expected to see either...
class Foo(val prop: Long) : RealmObject() {
...
}
or
class Foo (
val prop: Long
) : RealmObject() {
...
}
Yes, me too, but see pinterest/ktlint#163 (comment) |
@ouchadam yes, I agree with you,some constructors are not nicely formatted. Your latter proposal is good to me. As you said we can manually change that later, I wanted to keep manual commits as minimal as possible in this PR, since it's not possible to review it... |
Fixes #2820 |
Just under 600 files changed... 😅 Agreed: if ktlint accepts the current formatting, then this PR is acceptable. Apply the boy scout rule later when you work on lines of code with strange formatting. For class definitions with constructor arguments I prefer oneliners, but if too long I prefer to put arguments in one column, possibly even with a trailing comma after the last argument. The same goes for long lists of super types: first one comes after Is that how the current PR configure ktlint, so what I just said is acceptable formatting? |
another advantage is that dependabot is now able to upgrade the tool: #4138 :) |
Draft for now.
Iteration call to
./gradlew ktlintCheck
does not give the same result :/[EDIT]
It's OK now, ktlint plugin is working as expected.
The following rule are now enabled (were disabled before):
Fixes #2820