mirror of
https://github.com/github/codeql.git
synced 2025-12-18 01:33:15 +01:00
Python: Adds preliminary modernization
This commit is contained in:
@@ -12,8 +12,8 @@
|
||||
|
||||
import python
|
||||
|
||||
Function iter_method(ClassObject t) {
|
||||
result = ((FunctionObject)t.lookupAttribute("__iter__")).getFunction()
|
||||
Function iter_method(ClassValue t) {
|
||||
result = ((FunctionValue)t.lookup("__iter__")).getScope()
|
||||
}
|
||||
|
||||
predicate is_self(Name value, Function f) {
|
||||
@@ -28,6 +28,6 @@ predicate returns_non_self(Function f) {
|
||||
exists(Return r | r.getScope() = f and not exists(r.getValue()))
|
||||
}
|
||||
|
||||
from ClassObject t, Function iter
|
||||
from ClassValue t, Function iter
|
||||
where t.isIterator() and iter = iter_method(t) and returns_non_self(iter)
|
||||
select t, "Class " + t.getName() + " is an iterator but its $@ method does not return 'self'.", iter, iter.getName()
|
||||
Reference in New Issue
Block a user