diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/indentation/Checkers.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/indentation/Checkers.kt index af063a0e45..9808668585 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/indentation/Checkers.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/indentation/Checkers.kt @@ -59,8 +59,8 @@ import org.jetbrains.kotlin.psi.psiUtil.siblings */ internal class AssignmentOperatorChecker(configuration: IndentationConfig) : CustomIndentationChecker(configuration) { override fun checkNode(whiteSpace: PsiWhiteSpace, indentError: IndentationError): CheckResult? { - val prevNode = whiteSpace.prevSibling.node - if (prevNode.elementType == EQ && prevNode.treeNext.let { it.elementType == WHITE_SPACE && it.textContains('\n') }) { + val prevNode = whiteSpace.prevSibling?.node + if (prevNode?.elementType == EQ && prevNode.treeNext.let { it.elementType == WHITE_SPACE && it.textContains('\n') }) { return CheckResult.from(indentError.actual, (whiteSpace.parentIndent() ?: indentError.expected) + (if (configuration.extendedIndentAfterOperators) 2 else 1) * configuration.indentationSize, true) } @@ -256,8 +256,8 @@ internal class CustomGettersAndSettersChecker(config: IndentationConfig) : Custo */ internal class ArrowInWhenChecker(configuration: IndentationConfig) : CustomIndentationChecker(configuration) { override fun checkNode(whiteSpace: PsiWhiteSpace, indentError: IndentationError): CheckResult? { - val prevNode = whiteSpace.prevSibling.node - if (prevNode.elementType == ARROW && whiteSpace.parent is KtWhenEntry) { + val prevNode = whiteSpace.prevSibling?.node + if (prevNode?.elementType == ARROW && whiteSpace.parent is KtWhenEntry) { return CheckResult.from(indentError.actual, (whiteSpace.parentIndent() ?: indentError.expected) + configuration.indentationSize, true) } diff --git a/diktat-rules/src/test/resources/test/chapter6/compact_initialization/ApplyWithValueArgumentExpected.kt b/diktat-rules/src/test/resources/test/chapter6/compact_initialization/ApplyWithValueArgumentExpected.kt index 2a15290624..ade66872fe 100644 --- a/diktat-rules/src/test/resources/test/chapter6/compact_initialization/ApplyWithValueArgumentExpected.kt +++ b/diktat-rules/src/test/resources/test/chapter6/compact_initialization/ApplyWithValueArgumentExpected.kt @@ -9,4 +9,12 @@ httpClient.doRequest() fun setDefaultUrl(httpClient: HttpClient) { httpClient.url = "http://example.com" +} + +fun foo() { + val diktatExtension = project.extensions.create(DIKTAT_EXTENSION, DiktatExtension::class.java).apply { + inputs = project.fileTree("src").apply { + include("**/*.kt") + } + reporter = PlainReporter(System.out)} } \ No newline at end of file diff --git a/diktat-rules/src/test/resources/test/chapter6/compact_initialization/ApplyWithValueArgumentTest.kt b/diktat-rules/src/test/resources/test/chapter6/compact_initialization/ApplyWithValueArgumentTest.kt index 8abde5e9cd..517f2de76c 100644 --- a/diktat-rules/src/test/resources/test/chapter6/compact_initialization/ApplyWithValueArgumentTest.kt +++ b/diktat-rules/src/test/resources/test/chapter6/compact_initialization/ApplyWithValueArgumentTest.kt @@ -7,4 +7,12 @@ httpClient.doRequest() fun setDefaultUrl(httpClient: HttpClient) { httpClient.url = "http://example.com" +} + +fun foo() { + val diktatExtension = project.extensions.create(DIKTAT_EXTENSION, DiktatExtension::class.java) + diktatExtension.inputs = project.fileTree("src").apply { + include("**/*.kt") + } + diktatExtension.reporter = PlainReporter(System.out) } \ No newline at end of file