Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE in IndentationRule (during autofix) #555

Closed
petertrr opened this issue Nov 19, 2020 · 1 comment · Fixed by #596
Closed

NPE in IndentationRule (during autofix) #555

petertrr opened this issue Nov 19, 2020 · 1 comment · Fixed by #596
Assignees
Labels
autofix Issues related to diktat in autofix mode bug Something isn't working

Comments

@petertrr
Copy link
Member

Describe the bug

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)
}

yields

Caused by: java.lang.IllegalStateException: whiteSpace.prevSibling must not be null
	at org.cqfn.diktat.ruleset.utils.indentation.AssignmentOperatorChecker.checkNode(Checkers.kt:55) ~[diktat-rules-0.1.4.jar:na]
	at org.cqfn.diktat.ruleset.rules.files.IndentationRule.visitWhiteSpace(IndentationRule.kt:174) ~[diktat-rules-0.1.4.jar:na]
	at org.cqfn.diktat.ruleset.rules.files.IndentationRule.access$visitWhiteSpace(IndentationRule.kt:57) ~[diktat-rules-0.1.4.jar:na]
	at org.cqfn.diktat.ruleset.rules.files.IndentationRule$checkIndentation$1.invoke(IndentationRule.kt:156) ~[diktat-rules-0.1.4.jar:na]
	at org.cqfn.diktat.ruleset.rules.files.IndentationRule$checkIndentation$1.invoke(IndentationRule.kt:57) ~[diktat-rules-0.1.4.jar:na]

Environment information

  • diktat version: 0.1.4 (same for 0.1.5)
@petertrr petertrr added the bug Something isn't working label Nov 19, 2020
@petertrr petertrr self-assigned this Nov 19, 2020
@petertrr
Copy link
Member Author

This is because of interaction with CompactInitializationRule. If property assignments are wrapped into apply, there is not error.

@petertrr petertrr changed the title NPE in IndentationRule NPE in IndentationRule (during autofix) Nov 24, 2020
@petertrr petertrr added the autofix Issues related to diktat in autofix mode label Nov 24, 2020
@aktsay6 aktsay6 self-assigned this Dec 1, 2020
aktsay6 added a commit that referenced this issue Dec 1, 2020
### What's done:
  * Fixed bugs
aktsay6 added a commit that referenced this issue Dec 1, 2020
### What's done:
  * Fixed bugs
aktsay6 added a commit that referenced this issue Dec 1, 2020
### What's done:
  * Added this case to CompactInitialization fix tests
aktsay6 added a commit that referenced this issue Dec 1, 2020
# Conflicts:
#	diktat-rules/src/test/resources/test/smoke/src/main/kotlin/Example4Expected.kt
#	diktat-rules/src/test/resources/test/smoke/src/main/kotlin/Example4Test.kt
aktsay6 added a commit that referenced this issue Dec 3, 2020
### What's done:
  * Fixed bugs
aktsay6 added a commit that referenced this issue Dec 3, 2020
* bugfix/npe-indentation-rule(#555)

### What's done:
  * Fixed bugs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autofix Issues related to diktat in autofix mode bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants