mirror of
https://github.com/github/codeql.git
synced 2026-04-26 01:05:15 +02:00
AST: add consistency query
This commit is contained in:
20
ql/consistency-queries/AstConsistency.ql
Normal file
20
ql/consistency-queries/AstConsistency.ql
Normal file
@@ -0,0 +1,20 @@
|
||||
import codeql_ruby.AST
|
||||
|
||||
private string getAPrimaryQlClass(AstNode node) {
|
||||
result = node.getAPrimaryQlClass()
|
||||
or
|
||||
not exists(node.getAPrimaryQlClass()) and result = "(none)"
|
||||
}
|
||||
|
||||
query predicate missingParent(AstNode node, string cls) {
|
||||
not exists(node.getParent()) and
|
||||
node.getLocation().getFile().getExtension() != "erb" and
|
||||
not node instanceof Toplevel and
|
||||
cls = getAPrimaryQlClass(node)
|
||||
}
|
||||
|
||||
query predicate multipleParents(AstNode node, AstNode parent, string cls) {
|
||||
parent = node.getParent() and
|
||||
count(node.getParent()) > 1 and
|
||||
cls = getAPrimaryQlClass(parent)
|
||||
}
|
||||
Reference in New Issue
Block a user