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

Wrap lambda argument in call expression if max-line-length is exceeded #2085

Closed
paul-dingemans opened this issue Jun 22, 2023 · 1 comment
Closed

Comments

@paul-dingemans
Copy link
Collaborator

Given that the max-line-length is enabled and is exceeded, then wrap the content of the lambda expression in a call expression.

Example 1

require(someBooleanExpression) { "some longggggggggggggggggggggg message" }

should be formatted as:

require(someBooleanExpression) {
     "some longggggggggggggggggggggg message"
}

Example 2

In case the lambda argument has a value parameter:

val foo =
    listOf("a", "b", "c")
       .map { element -> element.toUppercase().repeat(5) }

should be formatted as:

val foo =
    listOf("a", "b", "c")
        .map { element ->
            element.toUppercase().repeat(5)
       }

Example 3

Whenever methods are chained on same line

val foo =  listOf("a", "b", "c").filter { it.isEligble() }.map { element -> element.toUppercase().repeat(5) }

the chained methods should first be wrapped (responsibility of different rule) to something like

val foo =
    listOf("a", "b", "c")
        .filter { it.isEligble() }
        .map { element -> element.toUppercase().repeat(5) }

and only when necessary be further wrapped to:

val foo =
    listOf("a", "b", "c")
        .filter { it.isEligble() }
        .map { element ->
            element.toUppercase().repeat(5)
        }
@paul-dingemans
Copy link
Collaborator Author

Solved by #2137

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

No branches or pull requests

1 participant