mirror of
https://github.com/github/codeql.git
synced 2026-04-20 14:34:04 +02:00
Python: Autoformat everything using qlformat.
Will need subsequent PRs fixing up test failures (due to deprecated methods moving around), but other than that everything should be straight-forward.
This commit is contained in:
@@ -16,15 +16,15 @@ import python
|
||||
predicate loop_variable(For f, Variable v) { f.getTarget().defines(v) }
|
||||
|
||||
predicate variableUsedInNestedLoops(For inner, For outer, Variable v) {
|
||||
/* Only treat loops in body as inner loops. Loops in the else clause are ignored. */
|
||||
outer.getBody().contains(inner) and
|
||||
loop_variable(inner, v) and
|
||||
loop_variable(outer, v) and
|
||||
/* Ignore cases where there is no use of the variable or the only use is in the inner loop */
|
||||
exists(Name n | n.uses(v) and outer.contains(n) and not inner.contains(n))
|
||||
/* Only treat loops in body as inner loops. Loops in the else clause are ignored. */
|
||||
outer.getBody().contains(inner) and
|
||||
loop_variable(inner, v) and
|
||||
loop_variable(outer, v) and
|
||||
/* Ignore cases where there is no use of the variable or the only use is in the inner loop */
|
||||
exists(Name n | n.uses(v) and outer.contains(n) and not inner.contains(n))
|
||||
}
|
||||
|
||||
from For inner, For outer, Variable v
|
||||
where variableUsedInNestedLoops(inner, outer, v)
|
||||
select inner, "Nested for statement uses loop variable '" + v.getId() + "' of enclosing $@.", outer,
|
||||
"for statement"
|
||||
"for statement"
|
||||
|
||||
Reference in New Issue
Block a user