mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Python: add default implementation of getName() and deprecate it
This commit is contained in:
@@ -154,8 +154,11 @@ abstract class Container extends @container {
|
||||
*/
|
||||
string toString() { result = this.getAbsolutePath() }
|
||||
|
||||
/** Gets the name of this container */
|
||||
abstract string getName();
|
||||
/**
|
||||
* Gets the name of this container.
|
||||
* DEPRECATED: Use `getAbsolutePath` instead.
|
||||
*/
|
||||
deprecated string getName() { result = this.getAbsolutePath() }
|
||||
|
||||
/**
|
||||
* Gets the relative path of this file or folder from the root folder of the
|
||||
@@ -327,7 +330,7 @@ abstract class Container extends @container {
|
||||
* paths. The list of paths is composed of the paths passed to the extractor and
|
||||
* `sys.path`.
|
||||
*/
|
||||
predicate isImportRoot(int n) { this.getName() = import_path_element(n) }
|
||||
predicate isImportRoot(int n) { this.getAbsolutePath() = import_path_element(n) }
|
||||
|
||||
/** Holds if this folder is the root folder for the standard library. */
|
||||
predicate isStdLibRoot(int major, int minor) {
|
||||
|
||||
@@ -184,7 +184,7 @@ class PackageObject extends ModuleObject {
|
||||
Location getLocation() { none() }
|
||||
|
||||
override predicate hasLocationInfo(string path, int bl, int bc, int el, int ec) {
|
||||
path = this.getPath().getName() and
|
||||
path = this.getPath().getAbsolutePath() and
|
||||
bl = 0 and
|
||||
bc = 0 and
|
||||
el = 0 and
|
||||
|
||||
@@ -259,7 +259,7 @@ predicate file_consistency(string clsname, string problem, string what) {
|
||||
exists(Container f |
|
||||
clsname = f.getAQlClass() and
|
||||
uniqueness_error(count(f.toString()), "toString", problem) and
|
||||
what = "file " + f.getName()
|
||||
what = "file " + f.getAbsolutePath()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ predicate of_interest(ControlFlowNode n, int line) {
|
||||
exists(Location l, File f | l = n.getLocation() |
|
||||
line = l.getStartLine() and
|
||||
f = l.getFile() and
|
||||
f.getName().matches("%test.py%") and
|
||||
f.getAbsolutePath().matches("%test.py%") and
|
||||
exists(Comment c |
|
||||
c.getLocation().getStartLine() < line and
|
||||
c.getLocation().getFile() = f
|
||||
|
||||
Reference in New Issue
Block a user