mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Rust: Move variable consistency check into AstConsistency.qll
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
/**
|
||||
* @name Variable inconsistencies
|
||||
* @description Lists the variable inconsistencies in the database. This query is intended for internal use.
|
||||
* @kind table
|
||||
* @id rust/diagnostics/variable-consistency
|
||||
*/
|
||||
|
||||
import codeql.rust.internal.VariableConsistency
|
||||
@@ -73,6 +73,14 @@ query predicate multiplePositions(Element parent, int pos1, int pos2, string acc
|
||||
pos1 != pos2
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `va` is a variable access that refers to multiple variables.
|
||||
*/
|
||||
query predicate multipleVariableTargets(VariableAccess va, Variable v1) {
|
||||
va = v1.getAnAccess() and
|
||||
strictcount(va.getVariable()) > 1
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets counts of abstract syntax tree inconsistencies of each type.
|
||||
*/
|
||||
@@ -98,4 +106,7 @@ int getAstInconsistencyCounts(string type) {
|
||||
or
|
||||
type = "Multiple positions" and
|
||||
result = count(Element e | multiplePositions(_, _, _, _, e) | e)
|
||||
or
|
||||
type = "Multiple variable targets" and
|
||||
result = count(VariableAccess va | multipleVariableTargets(va, _) | va)
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
/**
|
||||
* Provides logic for recognizing variable inconsistencies.
|
||||
*/
|
||||
|
||||
private import rust
|
||||
|
||||
query predicate multipleVariableTargets(VariableAccess va, Variable v1) {
|
||||
va = v1.getAnAccess() and
|
||||
strictcount(va.getVariable()) > 1
|
||||
}
|
||||
@@ -4,4 +4,5 @@
|
||||
| Multiple positions | 0 |
|
||||
| Multiple primary QL classes | 0 |
|
||||
| Multiple toStrings | 0 |
|
||||
| Multiple variable targets | 0 |
|
||||
| No location | 0 |
|
||||
|
||||
Reference in New Issue
Block a user