mirror of
https://github.com/github/codeql.git
synced 2026-05-01 19:55:15 +02:00
Python: Remove use of deprecated methods
This commit is contained in:
@@ -25,7 +25,7 @@ Object aFunctionLocalsObject() {
|
||||
|
||||
|
||||
predicate modification_of_locals(ControlFlowNode f) {
|
||||
f.(SubscriptNode).getValue().refersTo(aFunctionLocalsObject()) and (f.isStore() or f.isDelete())
|
||||
f.(SubscriptNode).getObject().refersTo(aFunctionLocalsObject()) and (f.isStore() or f.isDelete())
|
||||
or
|
||||
exists(string mname, AttrNode attr |
|
||||
attr = f.(CallNode).getFunction() and
|
||||
|
||||
@@ -65,7 +65,7 @@ predicate same_attribute(Attribute a1, Attribute a2) {
|
||||
|
||||
int pyflakes_commented_line(File file) {
|
||||
exists(Comment c | c.getText().toLowerCase().matches("%pyflakes%") |
|
||||
c.getLocation().hasLocationInfo(file.getName(), result, _, _, _)
|
||||
c.getLocation().hasLocationInfo(file.getAbsolutePath(), result, _, _, _)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ predicate mutates_globals(ModuleValue m) {
|
||||
|
|
||||
exists(AttrNode attr | attr.getObject() = globals)
|
||||
or
|
||||
exists(SubscriptNode sub | sub.getValue() = globals and sub.isStore())
|
||||
exists(SubscriptNode sub | sub.getObject() = globals and sub.isStore())
|
||||
)
|
||||
or
|
||||
exists(Value enum_convert, ClassValue enum_class |
|
||||
|
||||
@@ -206,8 +206,8 @@ predicate file_sanity(string clsname, string problem, string what) {
|
||||
exists(File file, Folder folder |
|
||||
clsname = file.getAQlClass() and
|
||||
problem = "has same name as a folder" and
|
||||
what = file.getName() and
|
||||
what = folder.getName()
|
||||
what = file.getAbsolutePath() and
|
||||
what = folder.getAbsolutePath()
|
||||
) or
|
||||
exists(Container f |
|
||||
clsname = f.getAQlClass() and
|
||||
|
||||
6
python/ql/src/external/DuplicateBlock.ql
vendored
6
python/ql/src/external/DuplicateBlock.ql
vendored
@@ -21,14 +21,14 @@ predicate sorted_by_location(DuplicateBlock x, DuplicateBlock y) {
|
||||
if x.sourceFile() = y.sourceFile() then
|
||||
x.sourceStartLine() < y.sourceStartLine()
|
||||
else
|
||||
x.sourceFile().getName() < y.sourceFile().getName()
|
||||
x.sourceFile().getAbsolutePath() < y.sourceFile().getAbsolutePath()
|
||||
}
|
||||
|
||||
from DuplicateBlock d, DuplicateBlock other
|
||||
where d.sourceLines() > 10 and
|
||||
other.getEquivalenceClass() = d.getEquivalenceClass() and
|
||||
sorted_by_location(other, d)
|
||||
select
|
||||
d,
|
||||
select
|
||||
d,
|
||||
"Duplicate code: " + d.sourceLines() + " lines are duplicated at " +
|
||||
other.sourceFile().getShortName() + ":" + other.sourceStartLine().toString()
|
||||
|
||||
@@ -10,16 +10,16 @@ class File extends Container {
|
||||
|
||||
/** DEPRECATED: Use `getAbsolutePath` instead. */
|
||||
deprecated override string getName() {
|
||||
files(this, result, _, _, _)
|
||||
result = this.getAbsolutePath()
|
||||
}
|
||||
|
||||
/** DEPRECATED: Use `getAbsolutePath` instead. */
|
||||
deprecated string getFullName() {
|
||||
result = getName()
|
||||
result = this.getAbsolutePath()
|
||||
}
|
||||
|
||||
predicate hasLocationInfo(string filepath, int bl, int bc, int el, int ec) {
|
||||
this.getName() = filepath and bl = 0 and bc = 0 and el = 0 and ec = 0
|
||||
this.getAbsolutePath() = filepath and bl = 0 and bc = 0 and el = 0 and ec = 0
|
||||
}
|
||||
|
||||
/** Whether this file is a source code file. */
|
||||
@@ -98,7 +98,7 @@ class Folder extends Container {
|
||||
|
||||
/** DEPRECATED: Use `getAbsolutePath` instead. */
|
||||
deprecated override string getName() {
|
||||
folders(this, result, _)
|
||||
result = this.getAbsolutePath()
|
||||
}
|
||||
|
||||
/** DEPRECATED: Use `getBaseName` instead. */
|
||||
@@ -107,7 +107,7 @@ class Folder extends Container {
|
||||
}
|
||||
|
||||
predicate hasLocationInfo(string filepath, int bl, int bc, int el, int ec) {
|
||||
this.getName() = filepath and bl = 0 and bc = 0 and el = 0 and ec = 0
|
||||
this.getAbsolutePath() = filepath and bl = 0 and bc = 0 and el = 0 and ec = 0
|
||||
}
|
||||
|
||||
override string getAbsolutePath() {
|
||||
@@ -427,11 +427,11 @@ class Location extends @location {
|
||||
}
|
||||
|
||||
string toString() {
|
||||
result = this.getPath().getName() + ":" + this.getStartLine().toString()
|
||||
result = this.getPath().getAbsolutePath() + ":" + this.getStartLine().toString()
|
||||
}
|
||||
|
||||
predicate hasLocationInfo(string filepath, int bl, int bc, int el, int ec) {
|
||||
exists(File f | f.getName() = filepath |
|
||||
exists(File f | f.getAbsolutePath() = filepath |
|
||||
locations_default(this, f, bl, bc, el, ec)
|
||||
or
|
||||
exists(Module m | m.getFile() = f |
|
||||
@@ -445,7 +445,7 @@ class Location extends @location {
|
||||
class Line extends @py_line {
|
||||
|
||||
predicate hasLocationInfo(string filepath, int bl, int bc, int el, int ec) {
|
||||
exists(Module m | m.getFile().getName() = filepath and
|
||||
exists(Module m | m.getFile().getAbsolutePath() = filepath and
|
||||
el = bl and bc = 1 and
|
||||
py_line_lengths(this, m, bl, ec))
|
||||
}
|
||||
|
||||
@@ -612,7 +612,7 @@ cached module PointsToInternal {
|
||||
exists(ControlFlowNode sys_modules_flow, ControlFlowNode n, ControlFlowNode mod |
|
||||
/* Use previous points-to here to avoid slowing down the recursion too much */
|
||||
exists(SubscriptNode sub |
|
||||
sub.getValue() = sys_modules_flow and
|
||||
sub.getObject() = sys_modules_flow and
|
||||
pointsTo(sys_modules_flow, _, ObjectInternal::sysModules(), _) and
|
||||
sub.getIndex() = n and
|
||||
n.getNode().(StrConst).getText() = name and
|
||||
|
||||
Reference in New Issue
Block a user