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

keyword-spacing triggering by right braces of a different statement #978

Closed
friscoMad opened this issue Nov 25, 2020 · 0 comments · Fixed by #980
Closed

keyword-spacing triggering by right braces of a different statement #978

friscoMad opened this issue Nov 25, 2020 · 0 comments · Fixed by #980
Labels

Comments

@friscoMad
Copy link

In our company we are enforcing to remove curly braces whenever possible for example in if that have a single statement, this lead us to find a situation that was not expected with keyword-spacing rule.

This is a new case of #756 that I have spotted in the wild

Expected Behavior

Do not require else to be in the same line of a right brace if the right brace is not part of the if statement.

Observed Behavior

[keyword-spacing] Unexpected newline before "else"

Steps to Reproduce

    if (foo != false)
        try {
            foo2()
        } catch (e: Throwable) {
            bar
        }
    else foo

Your Environment

  • Version of ktlint used: 0.39
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): org.jmailen.gradle:kotlinter-gradle:3.2.0
  • Version of Gradle used (if applicable): 6.7.1
  • Operating System and version: Mac OS Catalina 10.15.7
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants