mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
and consistency query that will highlight new consistency errors
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import ql
|
||||
import codeql_ql.ast.internal.AstNodes
|
||||
private import codeql_ql.ast.internal.AstNodes
|
||||
|
||||
private class TScope =
|
||||
TClass or TAggregate or TQuantifier or TSelect or TPredicate or TNewTypeBranch;
|
||||
@@ -89,4 +89,8 @@ module VarConsistency {
|
||||
decl = f.getDeclaration() and
|
||||
strictcount(f.getDeclaration()) > 1
|
||||
}
|
||||
|
||||
query predicate noFieldDef(FieldAccess f) { not exists(f.getDeclaration()) }
|
||||
|
||||
query predicate noVarDef(VarAccess v) { not exists(v.getDeclaration()) }
|
||||
}
|
||||
|
||||
37
ql/src/queries/diagnostics/EmptyConsistencies.ql
Normal file
37
ql/src/queries/diagnostics/EmptyConsistencies.ql
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @name Consistency predicate that should be empty
|
||||
* @description This query should have no results on the CodeQL repos.
|
||||
* It's marked as a warning query to make the results visible.
|
||||
* @kind problem
|
||||
* @problem.severity warning
|
||||
* @precision very-high
|
||||
* @id ql/diagnostics/empty-consitencies
|
||||
*/
|
||||
|
||||
import ql
|
||||
import codeql_ql.ast.internal.Predicate::PredConsistency as PredConsistency
|
||||
import codeql_ql.ast.internal.Type::TyConsistency as TypeConsistency
|
||||
import codeql_ql.ast.internal.Builtins::BuildinsConsistency as BuildinsConsistency
|
||||
import codeql_ql.ast.internal.Module::ModConsistency as ModConsistency
|
||||
import codeql_ql.ast.internal.Variable::VarConsistency as VarConsistency
|
||||
|
||||
from AstNode node, string msg
|
||||
where
|
||||
PredConsistency::noResolveCall(node) and msg = "PredConsistency::noResolveCall"
|
||||
or
|
||||
TypeConsistency::noResolve(node) and msg = "TypeConsistency::noResolve"
|
||||
or
|
||||
TypeConsistency::exprNoType(node) and msg = "TypeConsistency::exprNoType"
|
||||
or
|
||||
TypeConsistency::varDefNoType(node) and msg = "TypeConsistency::varDefNoType"
|
||||
or
|
||||
//or // has 1 result, but the CodeQL compiler also can't figure out that one. I suppoed the file is never imported.
|
||||
//TypeConsistency::noResolve(node) and msg = "TypeConsistency::noResolve"
|
||||
//or // has 1 result, but the CodeQL compiler also can't figure out that one. Same file as above.
|
||||
//ModConsistency::noResolve(node) and msg = "ModConsistency::noResolve"
|
||||
ModConsistency::noResolveModuleExpr(node) and msg = "ModConsistency::noResolveModuleExpr"
|
||||
or
|
||||
VarConsistency::noFieldDef(node) and msg = "VarConsistency::noFieldDef"
|
||||
or
|
||||
VarConsistency::noVarDef(node) and msg = "VarConsistency::noVarDef"
|
||||
select node, msg
|
||||
Reference in New Issue
Block a user