mirror of
https://github.com/github/codeql.git
synced 2026-01-03 09:40:17 +01:00
Will need subsequent PRs fixing up test failures (due to deprecated methods moving around), but other than that everything should be straight-forward.
27 lines
791 B
Plaintext
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()
|