Skip to content

Commit

Permalink
Fix false positive Missing newline after "->" when when entry has…
Browse files Browse the repository at this point in the history
… if/else block (#916)
  • Loading branch information
t-kameyama authored Sep 18, 2020
1 parent 6589349 commit 1f3b4b9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,7 @@ class IndentationRule : Rule("indent"), Rule.Modifier.RestrictToRootLast {
if (lToken != null && lToken.elementType in lTokenSet) {
val rElementType = matchingRToken[lToken.elementType]
val rToken = lToken.nextSibling { it.elementType == rElementType }
val lf = rToken?.nextLeaf { it.isWhiteSpaceWithNewline() }
return lf?.parent({ it == p }) == null
return rToken?.treeParent == lToken.treeParent
}
if (nextCodeSibling?.textContains('\n') == false) {
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ fun main() {
else -> 2 + 3
}
}
val v3 = when (1) {
1 -> if (true) {
2
} else {
3
}
else -> 0
}

val v4 = when (1) {
1 -> 1.let {
it + 1
}.let {
it + 1
}
else -> 0
}
}

// expect
Expand Down

0 comments on commit 1f3b4b9

Please sign in to comment.