diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/BooleanExpressionsRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/BooleanExpressionsRule.kt index ba0b06ee8b..63bc75fecb 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/BooleanExpressionsRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/BooleanExpressionsRule.kt @@ -180,7 +180,8 @@ class BooleanExpressionsRule(configRules: List) : DiktatRule( private fun checkDistributiveLaw( expr: Expression, mapOfExpressionToChar: HashMap, - node: ASTNode): String? { + node: ASTNode + ): String? { // checking that expression can be considered as distributive law val commonDistributiveOperand = getCommonDistributiveOperand(node, expr.toString(), mapOfExpressionToChar) ?: return null val correctSymbolsSequence = mapOfExpressionToChar.values.toMutableList() @@ -217,7 +218,8 @@ class BooleanExpressionsRule(configRules: List) : DiktatRule( private fun getCommonDistributiveOperand( node: ASTNode, expression: String, - mapOfExpressionToChar: HashMap): Char? { + mapOfExpressionToChar: HashMap + ): Char? { val operationSequence = expression.filter { it == '&' || it == '|' } val numberOfOperationReferences = operationSequence.length // There should be three operands and three operation references in order to consider the expression @@ -251,7 +253,8 @@ class BooleanExpressionsRule(configRules: List) : DiktatRule( private fun getCommonOperand( expression: String, firstSplitDelimiter: Char, - secondSplitDelimiter: Char): Char? { + secondSplitDelimiter: Char + ): Char? { val expressions = expression.split(firstSplitDelimiter) val listOfPairs: MutableList> = mutableListOf() expressions.forEach { expr -> diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LongNumericalValuesSeparatedRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LongNumericalValuesSeparatedRule.kt index 7fe8f58a14..f20c844f61 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LongNumericalValuesSeparatedRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LongNumericalValuesSeparatedRule.kt @@ -100,7 +100,8 @@ class LongNumericalValuesSeparatedRule(configRules: List) : DiktatR private fun isValidConstant( text: String, configuration: LongNumericalValuesConfiguration, - node: ASTNode): Boolean { + node: ASTNode + ): Boolean { if (text.contains("_")) { checkBlocks(removePrefixSuffix(text), configuration, node) return true diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt index 295a8d2612..2b776a5e5a 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt @@ -435,7 +435,8 @@ class NewlinesRule(configRules: List) : DiktatRule( (it.elementType == RPAR && it.treePrev.elementType != COMMA && !it.treePrev.isNewLineNode() && - it.treeParent.treeParent.findChildByType(TYPE_REFERENCE) != null) + it.treeParent.treeParent.children().dropWhile { it.elementType != COLON }.filter { it.elementType == TYPE_REFERENCE } + .toList().isNotEmpty()) } .toList() .takeIf { it.isNotEmpty() } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/WhiteSpaceRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/WhiteSpaceRule.kt index 8eb2bfe916..cef5e89a7f 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/WhiteSpaceRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/WhiteSpaceRule.kt @@ -407,7 +407,8 @@ class WhiteSpaceRule(configRules: List) : DiktatRule( private fun getDescription(shouldBefore: Boolean, shouldAfter: Boolean, before: Int?, - after: Int?): String = + after: Int? + ): String = if (shouldBefore && shouldAfter) { " $before space(s) before and $after space(s) after" } else if (shouldBefore && !shouldAfter) { diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/SmartCastRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/SmartCastRule.kt index f0a09c9aae..9add8096a1 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/SmartCastRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/SmartCastRule.kt @@ -117,7 +117,8 @@ class SmartCastRule(configRules: List) : DiktatRule( @Suppress("TYPE_ALIAS") private fun groupIsAndAsExpr(isExpr: List, asExpr: List, - prop: KtProperty): Map> { + prop: KtProperty + ): Map> { if (isExpr.isEmpty() && asExpr.isNotEmpty()) { handleZeroIsCase(asExpr, prop) return emptyMap()