Skip to content

Commit 6c666b4

Browse files
authored
Merge pull request github#6366 from smowton/smowton/fiix/junit-nested-classes
Prevent class-could-be-static alerts regarding JUnit Nested tests
2 parents 5d3e8d2 + aca905f commit 6c666b4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

java/ql/src/Performance/InnerClassCouldBeStatic.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ predicate potentiallyStatic(InnerClass c) {
127127
forall(InnerClass superOfNested | superOfNested = nested.getASourceSupertype+() |
128128
potentiallyStatic(superOfNested)
129129
)
130-
)
130+
) and
131+
// JUnit Nested test classes are required to be non-static.
132+
not c.hasAnnotation("org.junit.jupiter.api", "Nested")
131133
}
132134

133135
/**

0 commit comments

Comments
 (0)