Skip to content

Commit 4857a94

Browse files
committed
Swaps get_function_or_initializer globally
1 parent cf4b7e1 commit 4857a94

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

python/ql/src/Classes/WrongNameForArgumentInClassInstantiation.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Expressions.CallArgs
2121
from Call call, ClassObject cls, string name, FunctionObject init
2222
where
2323
illegally_named_parameter(call, cls, name)
24-
and init = get_function_or_initializer(cls)
24+
and init = get_function_or_initializer_objectapi(cls)
2525
select
2626
call, "Keyword argument '" + name + "' is not a supported parameter name of $@.", init, init.getQualifiedName()
2727

python/ql/src/Classes/WrongNumberArgumentsInClassInstantiation.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ where
2121
too_many_args(call, cls, limit) and too = "too many arguments" and should = "no more than "
2222
or
2323
too_few_args(call, cls, limit) and too = "too few arguments" and should = "no fewer than "
24-
) and init = get_function_or_initializer(cls)
24+
) and init = get_function_or_initializer_objectapi(cls)
2525
select call, "Call to $@ with " + too + "; should be " + should + limit.toString() + ".", init, init.getQualifiedName()

python/ql/src/Expressions/CallArgs.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ private Keyword not_keyword_only_arg_objectapi(Call call, FunctionObject func) {
2929
private int positional_arg_count_objectapi_for_call_objectapi(Call call, Object callable) {
3030
call = get_a_call_objectapi(callable).getNode() and
3131
exists(int positional_keywords |
32-
exists(FunctionObject func | func = get_function_or_initializer(callable) |
32+
exists(FunctionObject func | func = get_function_or_initializer_objectapi(callable) |
3333
not func.getFunction().hasKwArg() and
3434
positional_keywords = count(not_keyword_only_arg_objectapi(call, func))
3535
or
@@ -52,7 +52,7 @@ private ControlFlowNode get_a_call_objectapi(Object callable) {
5252
}
5353

5454
/* Gets the function object corresponding to the given class or function*/
55-
FunctionObject get_function_or_initializer(Object func_or_cls) {
55+
FunctionObject get_function_or_initializer_objectapi(Object func_or_cls) {
5656
result = func_or_cls.(FunctionObject)
5757
or
5858
result = func_or_cls.(ClassObject).declaredAttribute("__init__")
@@ -64,7 +64,7 @@ predicate illegally_named_parameter(Call call, Object func, string name) {
6464
not func.isC() and
6565
name = call.getANamedArgumentName() and
6666
call.getAFlowNode() = get_a_call_objectapi(func) and
67-
not get_function_or_initializer(func).isLegalArgumentName(name)
67+
not get_function_or_initializer_objectapi(func).isLegalArgumentName(name)
6868
}
6969

7070
/**Whether there are too few arguments in the `call` to `callable` where `limit` is the lowest number of legal arguments */
@@ -73,7 +73,7 @@ predicate too_few_args(Call call, Object callable, int limit) {
7373
not illegally_named_parameter(call, callable, _) and
7474
not exists(call.getStarargs()) and not exists(call.getKwargs()) and
7575
arg_count_objectapi(call) < limit and
76-
exists(FunctionObject func | func = get_function_or_initializer(callable) |
76+
exists(FunctionObject func | func = get_function_or_initializer_objectapi(callable) |
7777
call = func.getAFunctionCall().getNode() and limit = func.minParameters() and
7878
/* The combination of misuse of `mox.Mox().StubOutWithMock()`
7979
* and a bug in mox's implementation of methods results in having to
@@ -93,7 +93,7 @@ predicate too_many_args(Call call, Object callable, int limit) {
9393
// Exclude cases where an incorrect name is used as that is covered by 'Wrong name for an argument in a call'
9494
not illegally_named_parameter(call, callable, _) and
9595
exists(FunctionObject func |
96-
func = get_function_or_initializer(callable) and
96+
func = get_function_or_initializer_objectapi(callable) and
9797
not func.getFunction().hasVarArg() and limit >= 0
9898
|
9999
call = func.getAFunctionCall().getNode() and limit = func.maxParameters()

0 commit comments

Comments
 (0)