mirror of
https://github.com/github/codeql.git
synced 2026-03-17 04:56:58 +01:00
Python: Make sure that all Modules and ModuleObjects (even unused packages) have a working toString().
This commit is contained in:
@@ -9,9 +9,13 @@ class Module extends Module_, Scope, AstNode {
|
||||
override string toString() {
|
||||
result = this.getKind() + " " + this.getName()
|
||||
or
|
||||
/* No name is defined, which means that this is not on an import path. So it must be a script */
|
||||
/* No name is defined, which means that this module is not on an import path. So it must be a script */
|
||||
not exists(this.getName()) and not this.isPackage() and
|
||||
result = "Script " + this.getFile().getShortName()
|
||||
or
|
||||
/* Package missing name, so just use the path instead */
|
||||
not exists(this.getName()) and this.isPackage() and
|
||||
result = "Package at " + this.getPath().getAbsolutePath()
|
||||
}
|
||||
|
||||
/** This method will be deprecated in the next release. Please use `getEnclosingScope()` instead.
|
||||
|
||||
@@ -32,6 +32,9 @@ abstract class ModuleObject extends Object {
|
||||
|
||||
override string toString() {
|
||||
result = "Module " + this.getName()
|
||||
or
|
||||
not exists(this.getName()) and
|
||||
result = this.getModule().toString()
|
||||
}
|
||||
|
||||
/** Gets the named attribute of this module. Using attributeRefersTo() instead
|
||||
|
||||
Reference in New Issue
Block a user