mirror of
https://github.com/github/codeql.git
synced 2026-05-01 19:55:15 +02:00
Kotlin/Java: Add the beginnings of a "visibility" consistency query
This commit is contained in:
22
java/ql/consistency-queries/visibility.ql
Normal file
22
java/ql/consistency-queries/visibility.ql
Normal file
@@ -0,0 +1,22 @@
|
||||
import java
|
||||
|
||||
string visibility(Method m) {
|
||||
result = "public" and m.isPublic()
|
||||
or
|
||||
result = "protected" and m.isProtected()
|
||||
or
|
||||
result = "private" and m.isPrivate()
|
||||
or
|
||||
result = "internal" and m.isInternal()
|
||||
}
|
||||
|
||||
// TODO: This ought to check more than just methods
|
||||
from Method m
|
||||
where
|
||||
// TODO: This ought to work for everything, but for now we
|
||||
// restrict to things in Kotlin source files
|
||||
m.getFile().isKotlinSourceFile() and
|
||||
// TODO: This ought to have visibility information
|
||||
not m.getName() = "<clinit>" and
|
||||
count(visibility(m)) != 1
|
||||
select m, concat(visibility(m), ", ")
|
||||
Reference in New Issue
Block a user