From 19a8222b1d536b6abd276392b4f14299673bd629 Mon Sep 17 00:00:00 2001 From: Arrgentum Date: Wed, 15 Jun 2022 15:10:05 +0300 Subject: [PATCH] add check closed quoter ### Whats added: * corrected the logic of checking MultilionString * added fix test in IndentationRuleFixTest.kt - MultilionStringExpected.kt, MultilionStringTest.kt * delete smoke tests * run diktat:fix@diktat ### Issue (#811) --- .../ruleset/rules/chapter3/files/IndentationRule.kt | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/IndentationRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/IndentationRule.kt index 7b607bc9ce..8470c682fe 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/IndentationRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/IndentationRule.kt @@ -178,15 +178,8 @@ class IndentationRule(configRules: List) : DiktatRule( } } - private fun closeQuoterOffset(nodeWhiteSpace: ASTNode): Int { - val nextNode = nodeWhiteSpace.treeNext - val nextNodeDot = if (nextNode.elementType == DOT_QUALIFIED_EXPRESSION) { - nextNode - } else { - nextNode.getFirstChildWithType(DOT_QUALIFIED_EXPRESSION) - } - return nextNodeDot?.getFirstChildWithType(STRING_TEMPLATE)?.getFirstChildWithType(CLOSING_QUOTE)?.treePrev?.text?.length ?: -1 - } + private fun closeQuoterOffset(nodeWhiteSpace: ASTNode) = + nodeWhiteSpace.treeNext?.getFirstChildWithType(STRING_TEMPLATE)?.getFirstChildWithType(CLOSING_QUOTE)?.treePrev?.text?.length ?: -1 @Suppress("ForbiddenComment") private fun visitWhiteSpace(astNode: ASTNode, context: IndentContext) { @@ -217,7 +210,7 @@ class IndentationRule(configRules: List) : DiktatRule( val closeQuoterShift = closeQuoterOffset(astNode) - if ((checkResult?.isCorrect != true && expectedIndent != indentError.actual) || (closeQuoterShift != expectedIndent && closeQuoterShift > 0)) { + if ((checkResult?.isCorrect != true && expectedIndent != indentError.actual) || (closeQuoterShift != indentError.actual && closeQuoterShift > 0)) { WRONG_INDENTATION.warnAndFix(configRules, emitWarn, isFixMode, "expected $expectedIndent but was ${indentError.actual}", whiteSpace.startOffset + whiteSpace.text.lastIndexOf('\n') + 1, whiteSpace.node) { checkStringLiteral(whiteSpace, expectedIndent, indentError.actual)