Skip to content
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

FunctionExpressionBodyRule should replace all expression bodies in a single run #2394

Closed
paul-dingemans opened this issue Nov 30, 2023 · 0 comments · Fixed by #2395
Closed

Comments

@paul-dingemans
Copy link
Collaborator

Given code below, then multiple runs of ktlint are needed to replace all function bodies with body expressions:

fun foo1(): String {
    return "42"
}

fun foo2(): String {
    return "42"
}

fun foo3(): String {
    return "42"
}

fun foo4(): String {
    return "42"
}

fun foo5(): String {
    return "42"
}

Note that after first run of ktlint command, up to 3 function bodies are replaced, as ktlint will automatically run 3 times in case format violations have been fixed. Output after first run:

fun foo1(): String {
    return "42"
}

fun foo2(): String {
    return "42"
}

fun foo3(): String = "42"

fun foo4(): String = "42"

fun foo5(): String = "42"

Ktlint version: 1.0.1

@paul-dingemans paul-dingemans added this to the 1.1 milestone Nov 30, 2023
paul-dingemans added a commit that referenced this issue Nov 30, 2023
If a file contains multiple function bodies that have to be replaced with a body expression, then all should be replaced with a single run of ktlint.

Closes #2394
paul-dingemans added a commit that referenced this issue Dec 2, 2023
)

If a file contains multiple function bodies that have to be replaced with a body expression, then all should be replaced with a single run of ktlint.

Closes #2394
paul-dingemans added a commit that referenced this issue Dec 2, 2023
If a file contains multiple function bodies that have to be replaced with a body expression, then all should be replaced with a single run of ktlint.

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

Successfully merging a pull request may close this issue.

1 participant