Files
codeql/cpp/ql/src/Likely Bugs/NestedLoopSameVar.ql
Jonas Jensen 4ef5c9af62 C++: Autoformat everything
Some files that will change in #1736 have been spared.

    ./build -j4 target/jars/qlformat
    find ql/cpp/ql -name "*.ql"  -print0 | xargs -0 target/jars/qlformat --input
    find ql/cpp/ql -name "*.qll" -print0 | xargs -0 target/jars/qlformat --input
    (cd ql && git checkout 'cpp/ql/src/semmle/code/cpp/ir/implementation/**/*SSA*.qll')
    buildutils-internal/scripts/pr-checks/sync-identical-files.py --latest
2019-09-09 11:25:53 +02:00

20 lines
727 B
Plaintext

/**
* @name Nested loops with same variable
* @description When a nested loop uses the same iteration variable as its outer loop, the
* behavior of the outer loop easily becomes difficult to understand as the
* inner loop will affect its control flow. It is likely to be a typo.
* @kind problem
* @problem.severity warning
* @precision medium
* @id cpp/nested-loops-with-same-variable
* @tags maintainability
* correctness
*/
import NestedLoopSameVar
from ForStmt inner, Variable iteration, ForStmt outer
where nestedForViolation(inner, iteration, outer)
select inner.getCondition(), "Nested for statement uses loop variable $@ of enclosing $@.",
iteration, iteration.getName(), outer, "for statement"