openrewrite / openrewrite/rewrite-static-analysis
`NullPointerException` (NPE) in `NestedEnumsAreNotStatic`
Open
Nobody has claimed this yet.
bug
- Dominant language
- Java
- Stars
- 62
- Forks
- 112
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 40
Description
What version of OpenRewrite are you using?
8.67.1
How are you running OpenRewrite?
Moderne CLI
What is the smallest, simplest way to reproduce the problem?
mod run . --recipe CommonStaticAnalysis against https://github.com/awslabs/aws-saas-boost
What is the full stack trace of any errors you encountered?
"java.lang.NullPointerException: Cannot invoke "org.openrewrite.java.tree.J$Block.getPrefix()" because the return value of "org.openrewrite.java.tree.J$ClassDeclaration.getBody()" is null
org.openrewrite.java.format.SpacesVisitor.visitClassDeclaration(SpacesVisitor.java:722)
org.openrewrite.java.format.SpacesVisitor.visitClassDeclaration(SpacesVisitor.java:42)
org.openrewrite.java.tree.J$ClassDeclaration.acceptJava(J.java:1370)
org.openrewrite.java.tree.J.accept(J.java:55)
org.openrewrite.TreeVisitor.visit(TreeVisitor.java:242)
org.openrewrite.java.format.SpacesVisitor.visit(SpacesVisitor.java:741)
org.openrewrite.java.format.SpacesVisitor.visit(SpacesVisitor.java:42)
org.openrewrite.TreeVisitor.visit(TreeVisitor.java:154)
org.openrewrite.TreeVisitor.visitNonNull(TreeVisitor.java:173)
org.openrewrite.java.format.AutoFormatVisitor.visit(AutoFormatVisitor.java:74)
org.openrewrite.java.format.AutoFormatVisitor.visit(AutoFormatVisitor.java:34)
org.openrewrite.java.JavaVisitor.autoFormat(JavaVisitor.java:95)
org.openrewrite.java.JavaVisitor.maybeAutoFormat(JavaVisitor.java:76)
org.openrewrite.java.JavaVisitor.maybeAutoFormat(JavaVisitor.java:71)
org.openrewrite.java.JavaVisitor.maybeAutoFormat(JavaVisitor.java:67)
org.openrewrite.staticanalysis.NestedEnumsAreNotStatic$1.visitClassDeclaration(NestedEnumsAreNotStatic.java:66)
..."
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the Moderne CLI command against the linked aws-saas-boost revision, then inspect MetricEvent.java and NestedEnumsAreNotStatic.java. Follow the stack trace through SpacesVisitor.visitClassDeclaration and AutoFormatVisitor to determine why the class body is null. Done means CommonStaticAnalysis no longer raises this NullPointerException on the reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100