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

No braces added in multiline-if-else with dot qualified expression in else branche #2057

Closed
abouda opened this issue May 25, 2023 · 2 comments · Fixed by #2063
Closed

No braces added in multiline-if-else with dot qualified expression in else branche #2057

abouda opened this issue May 25, 2023 · 2 comments · Fixed by #2063

Comments

@abouda
Copy link

abouda commented May 25, 2023

Expected Behavior

ktlint -F multiline-if-else rule should add Braces for both if and else.

Observed Behavior

Braces added only for if
image

Steps to Reproduce

Write a multiline if/else statement without braces.
Run ktlint -F

Your Environment

  • Version of ktlint used: 0.49.1
  • Relevant parts of the .editorconfig settings
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): AGP 8.0.1
  • Version of Gradle used (if applicable): 8.1.1
  • Operating System and version: Mac OS 13.3.1 (a) (22E772610a)
@paul-dingemans paul-dingemans added this to the 0.49.2 / 0.50.x milestone May 25, 2023
@paul-dingemans
Copy link
Collaborator

The DOT QUALIFIED EXPRESSION prevents the braces from being added. It works for:

fun foo() {
    if (offset.value == 0) headerBackgroundColor()
    else headerBackgroundColor()
}

@paul-dingemans paul-dingemans changed the title ktlint -F multiline-if-else rule only adds braces for if statement and not else No braces added in multiline-if-else with dot qualified expression in else branche May 25, 2023
@atulgpt
Copy link
Contributor

atulgpt commented May 30, 2023

Hi, @paul-dingemans I have tried to fix this issue at #2063

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

Successfully merging a pull request may close this issue.

3 participants