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

29 lines
662 B
Plaintext

/**
* @name Module imports itself
* @description A module imports itself
* @kind problem
* @tags maintainability
* useless-code
* @problem.severity recommendation
* @sub-severity high
* @precision very-high
* @id py/import-own-module
*/
import python
predicate modules_imports_itself(ImportingStmt i, ModuleValue m) {
i.getEnclosingModule() = m.getScope() and
m =
max(string s, ModuleValue m_ |
s = i.getAnImportedModuleName() and
m_.importedAs(s)
|
m_ order by s.length()
)
}
from ImportingStmt i, ModuleValue m
where modules_imports_itself(i, m)
select i, "The module '" + m.getName() + "' imports itself."