mirror of
https://github.com/github/codeql.git
synced 2026-04-27 09:45:15 +02:00
Kotlin/Java: Add a (currently rather lax) cfgDeadEnds consistency query
This commit is contained in:
37
java/ql/consistency-queries/cfgDeadEnds.ql
Normal file
37
java/ql/consistency-queries/cfgDeadEnds.ql
Normal file
@@ -0,0 +1,37 @@
|
||||
import java
|
||||
import semmle.code.java.ControlFlowGraph
|
||||
|
||||
predicate shouldBeDeadEnd(ControlFlowNode n) {
|
||||
n.getFile().getExtension() = "kt" or // Kotlin currently has bugs
|
||||
n instanceof Interface or // TODO
|
||||
n instanceof Class or // TODO
|
||||
n instanceof Parameter or // TODO
|
||||
n instanceof Field or // TODO
|
||||
n instanceof Annotation or // TODO
|
||||
n instanceof TypeAccess or // TODO
|
||||
n instanceof ArrayTypeAccess or // TODO
|
||||
n instanceof UnionTypeAccess or // TODO
|
||||
n instanceof IntersectionTypeAccess or // TODO
|
||||
n instanceof ArrayAccess or // TODO
|
||||
n instanceof AddExpr or // TODO
|
||||
n instanceof MinusExpr or // TODO
|
||||
n instanceof LocalVariableDecl or // TODO
|
||||
n instanceof FieldDeclaration or // TODO
|
||||
n instanceof ArrayInit or // TODO
|
||||
n instanceof VarAccess or // TODO
|
||||
n instanceof Literal or // TODO
|
||||
n instanceof TypeLiteral or // TODO
|
||||
n instanceof TypeVariable or // TODO
|
||||
n instanceof WildcardTypeAccess or // TODO
|
||||
n instanceof MethodAccess or // TODO
|
||||
n instanceof Method or
|
||||
n instanceof Constructor or
|
||||
not exists(n.getFile().getRelativePath()) or // TODO
|
||||
n = any(ConstCase c).getValue(_) // TODO
|
||||
}
|
||||
|
||||
from ControlFlowNode n, string s
|
||||
where // TODO: exists(n.getASuccessor()) and shouldBeDeadEnd(n) and s = "expected dead end"
|
||||
not exists(n.getASuccessor()) and not shouldBeDeadEnd(n) and s = "unexpected dead end"
|
||||
select n, n.getPrimaryQlClasses(), s
|
||||
|
||||
Reference in New Issue
Block a user