Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Resolve conflict between binary-expression-wrapping and chain-wrapping #2492

Closed
paul-dingemans opened this issue Jan 7, 2024 · 0 comments · Fixed by #2493
Closed

Resolve conflict between binary-expression-wrapping and chain-wrapping #2492

paul-dingemans opened this issue Jan 7, 2024 · 0 comments · Fixed by #2493
Milestone

Comments

@paul-dingemans
Copy link
Collaborator

Given code below:

// Assume that the last allowed character is
// at the X character on the right                  X
val foo1 =
    foo(
        """longgggggggggggggggggggggggggggggggggg""" +
            """foo""",
    )
val foo2 =
    """longgggggggggggggggggggggggggggggggggggggg""" +
        """foo"""

then ktlint 1.1.0 reports following violations:

src/main/kotlin/Foo.kt:5:9: Line is exceeding max line length. Break line before expression (standard:binary-expression-wrapping)
src/main/kotlin/Foo.kt:5:54: Exceeded max line length (53) (standard:max-line-length)
src/main/kotlin/Foo.kt:9:54: Exceeded max line length (53) (standard:max-line-length)

(Interestingly, no error is reported on line 9.)

Wrapping the + operator at line 5 is however not allowed by chain-wrapping:

src/main/kotlin/Foo.kt:6:13: Line must not begin with "+" (standard:chain-wrapping)

binary-expression-wrapping should not suggest to wrap the left hand side of the expression when it is the root of the expression and only let the expression be reported by the max-line-length rule.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant