mirror of
https://github.com/github/codeql.git
synced 2026-01-15 07:24:49 +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.
29 lines
662 B
Plaintext
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."
|