Skip to content

Exclude inner classes annotated with @Nested from ClassCanBeStatic rule #956

@uhafner

Description

@uhafner

Please answer these questions before submitting your issue. Thanks!

What version of Error Prone are you using?

2.2.0 (with maven.plugin 2.8.2)

Does this issue reproduce with the latest release?

Yes

What did you do?

JUnit 5 provides nested tests using an inner class (not static): See Example at https://junit.org/junit5/docs/current/user-guide/#writing-tests-nested

If I use the rule ClassCanBeStatic on all my classes, then all those tests are flagged.

What did you expect to see?

An inner class with the annotation @org.junit.jupiter.api.Nested should not be flagged as warning.

What did you see instead?

[WARNING] /Users/hafner/Development/jenkins/workspace/Pipeline/src/test/java/edu/hm/hafner/analysis/parser/dry/CodeDuplicationTest.java:[64,5] [ClassCanBeStatic] Inner class is non-static but does not reference enclosing class

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions