Files
codeql/python/ql/src/Imports/CyclicImport.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

27 lines
791 B
Plaintext

/**
* @name Cyclic import
* @description Module forms part of an import cycle, thereby indirectly importing itself.
* @kind problem
* @tags reliability
* maintainability
* modularity
* @problem.severity recommendation
* @sub-severity low
* @precision high
* @id py/cyclic-import
*/
import python
import Cyclic
from ModuleValue m1, ModuleValue m2, Stmt imp
where
imp.getEnclosingModule() = m1.getScope() and
stmt_imports(imp) = m2 and
circular_import(m1, m2) and
m1 != m2 and
// this query finds all cyclic imports that are *not* flagged by ModuleLevelCyclicImport
not failing_import_due_to_cycle(m2, m1, _, _, _, _) and
not exists(If i | i.isNameEqMain() and i.contains(imp))
select imp, "Import of module $@ begins an import cycle.", m2, m2.getName()