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 BlockStructureBraces when there are two nested ifs without braces #481

Closed
petertrr opened this issue Nov 2, 2020 · 0 comments · Fixed by #502
Closed

NPE in BlockStructureBraces when there are two nested ifs without braces #481

petertrr opened this issue Nov 2, 2020 · 0 comments · Fixed by #502
Assignees
Labels
bug Something isn't working

Comments

@petertrr
Copy link
Member

petertrr commented Nov 2, 2020

Describe the bug

class Example {
    fun foo() {
        if (condition1)
            if (condition2)
                bar()
    }
}

Expected behavior

All ifs should get surrounded with braces.

Observed behavior

java.lang.NullPointerException
    at org.jetbrains.kotlin.com.intellij.psi.impl.source.codeStyle.CodeEditUtil.saveWhitespacesInfo (CodeEditUtil.java:122)
    at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.ChangeUtil.saveIndentationToCopy (ChangeUtil.java:106)
    at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.ChangeUtil.copyLeafWithText (ChangeUtil.java:82)
    at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.LeafElement.replaceWithText (LeafElement.java:154)
    at org.cqfn.diktat.ruleset.rules.BlockStructureBraces$checkOpenBraceOnSameLine$1.invoke (BlockStructureBraces.kt:181)
    at org.cqfn.diktat.ruleset.rules.BlockStructureBraces$checkOpenBraceOnSameLine$1.invoke (BlockStructureBraces.kt:53)

Environment information

  • diktat version: 0.1.3
  • build tool (maven/gradle): maven
  • how is diktat run (CLI, plugin, etc.): plugin
  • kotlin version: 1.4.10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants