Python: Fix FPs for py/import-own-module

Before I added `--max-import-depth=2`, there was a bit of trouble, where it
would alert on `from pkg_ok import foo2` -- since all the `pkg_ok.foo<n>`
modules were missing, I guess the analysis didn't make any assumptions on
whether `foo2` is a module or a regular attribute.
This commit is contained in:
Rasmus Wriedt Larsen
2020-02-11 11:37:01 +01:00
parent f3f9e340d3
commit 5cc2efef8e
4 changed files with 12 additions and 12 deletions

View File

@@ -14,7 +14,12 @@ import python
predicate modules_imports_itself(Import i, ModuleValue m) {
i.getEnclosingModule() = m.getScope() and
m.importedAs(i.getAnImportedModuleName())
m = max(string s, ModuleValue m_ |
s = i.getAnImportedModuleName() and
m_.importedAs(s)
|
m_ order by s.length()
)
}
from Import i, ModuleValue m