Files
codeql/python/ql/src/Imports/ImportShadowedByLoopVar.ql
Taus Brock-Nannestad f07a7bf8cf 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.
2020-07-07 15:43:52 +02:00

26 lines
676 B
Plaintext

/**
* @name Import shadowed by loop variable
* @description A loop variable shadows an import.
* @kind problem
* @tags maintainability
* @problem.severity recommendation
* @sub-severity low
* @deprecated
* @precision very-high
* @id py/import-shadowed-loop-variable
*/
import python
predicate shadowsImport(Variable l) {
exists(Import i, Name shadow |
shadow = i.getAName().getAsname() and
shadow.getId() = l.getId() and
i.getScope() = l.getScope().getScope*()
)
}
from Variable l, Name defn
where shadowsImport(l) and defn.defines(l) and exists(For for | defn = for.getTarget())
select defn, "Loop variable '" + l.getId() + "' shadows an import"