saveourtool / diktat

Strict coding standard for Kotlin and a custom set of rules for detecting code smells, code style issues and bugs
https://diktat.saveourtool.com
MIT License
521 stars 39 forks source link

No newlines between two consecutive }} after first run of diktat #407

Closed petertrr closed 3 years ago

petertrr commented 3 years ago

The code

when (node.elementType) {
            CLASS, FUN, PRIMARY_CONSTRUCTOR, SECONDARY_CONSTRUCTOR -> checkAnnotation(node)
}

is being fixed to

when (node.elementType) {
            CLASS, FUN, PRIMARY_CONSTRUCTOR, SECONDARY_CONSTRUCTOR -> checkAnnotation(node)

            else -> {
                // this is a generated else block
            }}

even though there should be a newline before the lase }

petertrr commented 3 years ago

This is actually not NewlinesRule but rather BlockStructureBraces rule. It's placed higher in rule set provider that WhenMustHaveElse. The code in the example is correctly fixed in diktat on the second run.