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

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

Closed
friscoMad opened this issue Jun 1, 2020 · 1 comment · Fixed by #801
Closed

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

friscoMad opened this issue Jun 1, 2020 · 1 comment · Fixed by #801
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.

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

Redacted code based on real code, that should triggers the error.

            if (foo != false)
                when (bar) {
                    A -> {
                       foo2.bar(1)
                    }
                    B -> foo2.bar(2)
                    C, D-> {
                       foo2.bar(3)
                    }
                }
            else log.info("foo")

Your Environment

  • Version of ktlint used: 0.36
  • 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:2.2.0
  • Version of Gradle used (if applicable): 6.2.2
  • Operating System and version: MacOs Catalina 10.15.4
@shashachu shashachu added the bug label Jun 1, 2020
@shashachu
Copy link
Contributor

Thanks for reporting. This looks like it was partially fixed in commit 30a476b but this appears to be another edge case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants