Skip to content

Commit fcb3d78

Browse files
authored
Merge pull request #9146 from tamasvajk/kotlin-inner-class-static
Kotlin: exclude Kotlin source from 'inner class could be static' check
2 parents 26553ce + 631ba8a commit fcb3d78

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

java/ql/src/Performance/InnerClassCouldBeStatic.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ predicate potentiallyStatic(InnerClass c) {
130130
)
131131
) and
132132
// JUnit Nested test classes are required to be non-static.
133-
not c.hasAnnotation("org.junit.jupiter.api", "Nested")
133+
not c.hasAnnotation("org.junit.jupiter.api", "Nested") and
134+
// There's no `static` in kotlin:
135+
not c.getLocation().getFile().isKotlinSourceFile()
134136
}
135137

136138
/**

java/ql/test/kotlin/query-tests/InnerClassCouldBeStatic/InnerClassCouldBeStatic.expected

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Performance/InnerClassCouldBeStatic.ql
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class A {
2+
fun fn1() {}
3+
companion object {
4+
fun fn2() {}
5+
}
6+
}

0 commit comments

Comments
 (0)