Merge branch 'master' into python-objectapi-to-valueapi-incorrectlyoverridenmethod

This commit is contained in:
Rebecca Valentine
2020-04-22 09:40:33 -07:00
223 changed files with 8046 additions and 12862 deletions

View File

@@ -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 + "'"
)
)

View File

@@ -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() +