mirror of
https://github.com/github/codeql.git
synced 2025-12-18 01:33:15 +01:00
Merge branch 'master' into python-objectapi-to-valueapi-incorrectlyoverridenmethod
This commit is contained in:
@@ -13,21 +13,21 @@
|
||||
import python
|
||||
import Expressions.CallArgs
|
||||
|
||||
from Call call, FunctionObject func, FunctionObject overriding, string problem
|
||||
from Call call, FunctionValue func, FunctionValue overriding, string problem
|
||||
where
|
||||
not func.getName() = "__init__" and
|
||||
overriding.overrides(func) and
|
||||
call = overriding.getAMethodCall().getNode() and
|
||||
correct_args_if_called_as_method_objectapi(call, overriding) and
|
||||
correct_args_if_called_as_method(call, overriding) and
|
||||
(
|
||||
arg_count_objectapi(call) + 1 < func.minParameters() and problem = "too few arguments"
|
||||
arg_count(call) + 1 < func.minParameters() and problem = "too few arguments"
|
||||
or
|
||||
arg_count_objectapi(call) >= func.maxParameters() and problem = "too many arguments"
|
||||
arg_count(call) >= func.maxParameters() and problem = "too many arguments"
|
||||
or
|
||||
exists(string name |
|
||||
call.getAKeyword().getArg() = name and
|
||||
overriding.getFunction().getAnArg().(Name).getId() = name and
|
||||
not func.getFunction().getAnArg().(Name).getId() = name and
|
||||
overriding.getScope().getAnArg().(Name).getId() = name and
|
||||
not func.getScope().getAnArg().(Name).getId() = name and
|
||||
problem = "an argument named '" + name + "'"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -12,18 +12,10 @@
|
||||
|
||||
import python
|
||||
|
||||
ClassObject return_type(FunctionObject f) {
|
||||
exists(ControlFlowNode n, Return ret |
|
||||
ret.getScope() = f.getFunction() and
|
||||
ret.getValue() = n.getNode() and
|
||||
n.refersTo(_, result, _)
|
||||
)
|
||||
}
|
||||
|
||||
from ClassObject iterable, FunctionObject iter, ClassObject iterator
|
||||
from ClassValue iterable, FunctionValue iter, ClassValue iterator
|
||||
where
|
||||
iter = iterable.lookupAttribute("__iter__") and
|
||||
iterator = return_type(iter) and
|
||||
iter = iterable.lookup("__iter__") and
|
||||
iterator = iter.getAnInferredReturnType() and
|
||||
not iterator.isIterator()
|
||||
select iterator,
|
||||
"Class " + iterator.getName() +
|
||||
|
||||
Reference in New Issue
Block a user