You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A practical example, single println (please ignore the fact it doesn't use string template : ) :
println("ver: " + libs.versions.our.lib.get())
Expected Behavior
Line is left verbatim. Length is OK, the property access via Gradle version catalog accessor it perfectly OK, and the getter for the Property<String> is unfortunately necessary due to Gradle's internals (no good toString() there) - however since we do not have a method chain (only a single explicit method is called, the rest is either accessors or fields or whatever, no () anyway), no chain-method-continuation rule should trigger - since there is no chained method nor any continuation happening)
Observed Behavior
a waterfall of tragedies follows:
first, the chain rule triggers, so it gets reformatted to
println("ver: " + libs.versions.our.lib
.get())
then, the wrapping and multiline-expression-wrapping rules trigger, resulting in
It's now a lot harder to read and handle - and, let's be honest - in total that's a real overkill, that could be safely prevented by a tweak to the chain-method-continuation logic :)
Steps to Reproduce
Take any expression that has >= 3 property etc. accesses (even with very short names!), and terminate with a method call.
Note that this won't happen for pure property access, nor for <= 2 property accesses like libs.versieeeeeons.ooooooooour.getLibrary()
Proposed solution
Don't treat a stream of tokens as a "chained method call" if only a single () method is called at the end.
Your Environment
ktlint ruleset 1.5.0
The text was updated successfully, but these errors were encountered:
related to #2455 , mirroring the idea from #2455 (comment) somewhat; results from IMVHO excessive application of
chain-method-continuation
, coupled with the default value of https://pinterest.github.io/ktlint/1.0.0/rules/configuration-ktlint/#force-multiline-chained-methods-based-on-number-of-chain-operatorsA practical example, single
println
(please ignore the fact it doesn't use string template : ) :Expected Behavior
Line is left verbatim. Length is OK, the property access via Gradle version catalog accessor it perfectly OK, and the getter for the
Property<String>
is unfortunately necessary due to Gradle's internals (no goodtoString()
there) - however since we do not have a method chain (only a single explicit method is called, the rest is either accessors or fields or whatever, no()
anyway), no chain-method-continuation rule should trigger - since there is no chained method nor any continuation happening)Observed Behavior
a waterfall of tragedies follows:
wrapping
andmultiline-expression-wrapping
rules trigger, resulting inIt's now a lot harder to read and handle - and, let's be honest - in total that's a real overkill, that could be safely prevented by a tweak to the
chain-method-continuation
logic :)Steps to Reproduce
Take any expression that has >= 3 property etc. accesses (even with very short names!), and terminate with a method call.
Note that this won't happen for pure property access, nor for <= 2 property accesses like
libs.versieeeeeons.ooooooooour.getLibrary()
Proposed solution
Don't treat a stream of tokens as a "chained method call" if only a single
()
method is called at the end.Your Environment
ktlint ruleset 1.5.0
The text was updated successfully, but these errors were encountered: