Skip to content

Commit

Permalink
Fixed IndentationRule
Browse files Browse the repository at this point in the history
### What's done:
- Fixed bug related to string templates starting with new line.

It's part of #1737
  • Loading branch information
DrAlexD committed Oct 5, 2023
1 parent 2c10a00 commit 242b6f2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ class IndentationRule(configRules: List<RulesConfig>) : DiktatRule(
addException(exceptionInitiatorNode, expectedIndent - indentError.expected, checkResult.includeLastChild)
}

if (astNode.treeParent.elementType == LONG_STRING_TEMPLATE_ENTRY && indentError.expected != indentError.actual) {
addException(astNode.treeParent, abs(indentError.expected - indentError.actual), false)
if (astNode.treeParent.elementType == LONG_STRING_TEMPLATE_ENTRY && astNode.treeNext.elementType != LONG_TEMPLATE_ENTRY_END) {
addException(astNode.treeParent, SINGLE.level() * configuration.indentationSize, false)
}

val alignedOpeningAndClosingQuotes = hasAlignedOpeningAndClosingQuotes(astNode, indentError.actual)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import com.saveourtool.diktat.util.FixTestBase
import generated.WarningNames
import org.assertj.core.api.Assertions.assertThat
import org.intellij.lang.annotations.Language
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Test
Expand Down Expand Up @@ -57,7 +56,6 @@ class IndentationRuleFixTest : FixTestBase("test/paragraph3/indentation",
fixAndCompare("IndentationParametersExpected.kt", "IndentationParametersTest.kt")
}

@Disabled("https://github.com/saveourtool/diktat/issues/1737")
@Test
@Tag(WarningNames.WRONG_INDENTATION)
fun `indentation rule - example 1`() {
Expand Down

0 comments on commit 242b6f2

Please sign in to comment.