Skip to content

Commit

Permalink
Fix Conflicting TOO_MANY_BLANK_LINES and BRACES_BLOCK_STRUCTURE_ERROR…
Browse files Browse the repository at this point in the history
… with empty block

### What's done:
* Fixed Conflicting TOO_MANY_BLANK_LINES and BRACES_BLOCK_STRUCTURE_ERROR with empty block in lambda
  • Loading branch information
Cheshiriks committed Mar 12, 2021
1 parent 9544845 commit 7a64998
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class BlockStructureBraces(configRules: List<RulesConfig>) : DiktatRule(
}
var space = node.findChildByType(RBRACE)!!.treePrev
node.findParentNodeWithSpecificType(ElementType.LAMBDA_ARGUMENT)?.let {
if (space.text == "") {
if (space.text.isEmpty()) {
space = space.treePrev
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class BlankLinesRule(configRules: List<RulesConfig>) : DiktatRule(
it.elementType == CLASS_BODY || it.elementType == FUNCTION_LITERAL
}) {
node.findParentNodeWithSpecificType(LAMBDA_ARGUMENT)?.let {
// Lambda body is always has a BLOCK -> run { } - (LBRACE, WHITE_SPACE, BLOCK "", RBRACE)
if ((node.treeNext?.treeNext?.elementType == RBRACE) && (node.treePrev.elementType == LBRACE)) {
val freeText = "do not put newlines in empty lambda"
TOO_MANY_BLANK_LINES.warnAndFix(configRules, emitWarn, isFixMode, freeText, node.startOffset, node) {
Expand Down

0 comments on commit 7a64998

Please sign in to comment.