-
Notifications
You must be signed in to change notification settings - Fork 503
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
Non chained calls should be on the same line if short enough #1077
Comments
I am not sure that such rule should exist as such style is subjective - in more complex scenarios some people tend to move Not related directly to the topic - KtLint didn't complain about empty line between |
No, when run like this: Version:
|
Fixed in #1105 |
I'm still unsure about codebases where something like: someLongVariable
.someNonChainedCall() would be normal. Do you have such an example? I can think of things like
but even then I don't know if people would format it this way unless it breaks the line limit. In any case free to close if you don't think it makes sense to implement this. |
* Lint/format needless blank lines in dot qualified expression (#1077) * Lint/format needless blank lines in dot qualified expression (#1077) Co-authored-by: Paul Dingemans <pdingemans@bol.com> Co-authored-by: Roman Zavarnitsyn <rom4ek93@gmail.com> Co-authored-by: Yahor Berdnikau <egorr.berd@gmail.com>
It is very subjective and if you still want to have it - best option for you would be to implement custom rule. |
* Lint/format needless blank lines in dot qualified expression (pinterest#1077) * Lint/format needless blank lines in dot qualified expression (pinterest#1077) Co-authored-by: Paul Dingemans <pdingemans@bol.com> Co-authored-by: Roman Zavarnitsyn <rom4ek93@gmail.com> Co-authored-by: Yahor Berdnikau <egorr.berd@gmail.com>
Expected Rule behavior
Right now, ktlint (with
--experimental
) does not complain with this snippet:In this case, since
3.compareTo(2)
is shorter than the maximum line length and it does not consist of chained calls, and it should be written in one line. With long arguments, it should still look like3.compareTo(
with the arguments on the next lines.This kind of superfluous / misleading line breaks can happen with automatic conversion from Java to Kotlin using Android Studio.
Additional information
The text was updated successfully, but these errors were encountered: