From 45864c0a1e371ce3f48b74b1c910f0eb45b6a2c0 Mon Sep 17 00:00:00 2001 From: kentr0w Date: Fri, 30 Apr 2021 17:01:16 +0300 Subject: [PATCH] Incorrect fix of null-safety rule ### What's done: Fixed according to our code-style --- .../cqfn/diktat/ruleset/rules/chapter4/NullChecksRule.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/NullChecksRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/NullChecksRule.kt index 401072cc99..f52999d07e 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/NullChecksRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/NullChecksRule.kt @@ -126,7 +126,7 @@ class NullChecksRule(configRules: List) : DiktatRule( if (condition.getBreakNodeFromIf(THEN)) { "$variableName ?: break" } else { - "$variableName ?: run {${thenCodeLines?.joinToString(prefix = "\n" , postfix = "\n", separator = "\n")}}" + "$variableName ?: run {${thenCodeLines?.joinToString(prefix = "\n", postfix = "\n", separator = "\n")}}" } thenCodeLines!!.singleOrNull() == "null" -> """ |$variableName?.let { @@ -150,9 +150,9 @@ class NullChecksRule(configRules: List) : DiktatRule( } else { when { elseCodeLines.isNullOrEmpty() || (elseCodeLines.singleOrNull() == "null") -> - "$variableName?.let {${thenCodeLines?.joinToString(prefix = "\n" , postfix = "\n", separator = "\n")}}" + "$variableName?.let {${thenCodeLines?.joinToString(prefix = "\n", postfix = "\n", separator = "\n")}}" elseCodeLines.singleOrNull() == "break" -> - "$variableName?.let {${thenCodeLines?.joinToString(prefix = "\n" , postfix = "\n", separator = "\n")}} ?: break" + "$variableName?.let {${thenCodeLines?.joinToString(prefix = "\n", postfix = "\n", separator = "\n")}} ?: break" else -> """ |$variableName?.let { |${thenCodeLines?.joinToString(separator = "\n")} @@ -205,7 +205,7 @@ class NullChecksRule(configRules: List) : DiktatRule( .treeParent .findChildByType(type) ?.let { it.findChildByType(BLOCK) ?: it } - ?.findAllNodesWithCondition({it.elementType == BREAK})?.isNotEmpty() + ?.findAllNodesWithCondition({ it.elementType == BREAK })?.isNotEmpty() ?: false private fun ASTNode.extractLinesFromBlock(type: IElementType): List? =