-
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
Conflict between range-spacing
and curly-spacing
#2539
Comments
Yes, it is a bug when rules are conflicting. But you can also see it as a sign that the code is not clear. The combination of a method chain with range operator is not very readable. I don't like any of the alternatives below.
Due to space before '{ it }
This does not seem to be consistent. Why is space used before the range operator and not after it.
This looks consistent for this particular line. But it will not be consistent with other lines in which the range operator is used with integer constants in left and right hand side of operator. In case that a variable is used like in code below, ktlint will not report any violations. So, the best approach to resolve th conflict seems to be that the
For now, you can just suppress this specific example. |
I completely agree. I'd even favor a rule that disallows braces or other complex expressions from being part of a range. |
Expected Behavior
range-spacing
andcurly-spacing
should work together.Observed Behavior
It is possible to write code which makes it impossible to satisfy both rules.
Steps to Reproduce
Try to lint or format the following code.
If the
}
is directly before the.
,curly-spacing
will fail. If a space is added in between them,range-spacing
will fail.Your Environment
The text was updated successfully, but these errors were encountered: