Skip to content

Commit cf4b7e1

Browse files
committed
Swaps arg_count globally
1 parent c2a3af7 commit cf4b7e1

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

python/ql/src/Expressions/CallArgs.qll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ private Keyword not_keyword_only_arg_objectapi(Call call, FunctionObject func) {
2626
* plus the number of keyword arguments that do not match keyword-only arguments (if the function does not take **kwargs).
2727
*/
2828

29-
private int positional_arg_count_for_call_objectapi(Call call, Object callable) {
29+
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 |
3232
exists(FunctionObject func | func = get_function_or_initializer(callable) |
@@ -40,7 +40,7 @@ private int positional_arg_count_for_call_objectapi(Call call, Object callable)
4040
)
4141
}
4242

43-
int arg_count(Call call) {
43+
int arg_count_objectapi(Call call) {
4444
result = count(call.getAnArg()) + varargs_length_objectapi(call) + count(call.getAKeyword())
4545
}
4646

@@ -72,7 +72,7 @@ predicate too_few_args(Call call, Object callable, int limit) {
7272
// Exclude cases where an incorrect name is used as that is covered by 'Wrong name for an argument in a call'
7373
not illegally_named_parameter(call, callable, _) and
7474
not exists(call.getStarargs()) and not exists(call.getKwargs()) and
75-
arg_count(call) < limit and
75+
arg_count_objectapi(call) < limit and
7676
exists(FunctionObject func | func = get_function_or_initializer(callable) |
7777
call = func.getAFunctionCall().getNode() and limit = func.minParameters() and
7878
/* The combination of misuse of `mox.Mox().StubOutWithMock()`
@@ -103,7 +103,7 @@ predicate too_many_args(Call call, Object callable, int limit) {
103103
callable instanceof ClassObject and
104104
call.getAFlowNode() = get_a_call_objectapi(callable) and limit = func.maxParameters() - 1
105105
) and
106-
positional_arg_count_for_call_objectapi(call, callable) > limit
106+
positional_arg_count_objectapi_for_call_objectapi(call, callable) > limit
107107
}
108108

109109
/** Holds if `call` has too many or too few arguments for `func` */
@@ -118,9 +118,9 @@ predicate wrong_args(Call call, FunctionObject func, int limit, string too) {
118118
*/
119119
bindingset[call, func]
120120
predicate correct_args_if_called_as_method(Call call, FunctionObject func) {
121-
arg_count(call)+1 >= func.minParameters()
121+
arg_count_objectapi(call)+1 >= func.minParameters()
122122
and
123-
arg_count(call) < func.maxParameters()
123+
arg_count_objectapi(call) < func.maxParameters()
124124
}
125125

126126
/** Holds if `call` is a call to `overriding`, which overrides `func`. */

python/ql/src/Functions/IncorrectlySpecifiedOverriddenMethod.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ overriding.overrides(func) and
2020
call = overriding.getAMethodCall().getNode() and
2121
correct_args_if_called_as_method(call, overriding) and
2222
(
23-
arg_count(call)+1 < func.minParameters() and problem = "too few arguments"
23+
arg_count_objectapi(call)+1 < func.minParameters() and problem = "too few arguments"
2424
or
25-
arg_count(call) >= func.maxParameters() and problem = "too many arguments"
25+
arg_count_objectapi(call) >= func.maxParameters() and problem = "too many arguments"
2626
or
2727
exists(string name | call.getAKeyword().getArg() = name and
2828
overriding.getFunction().getAnArg().(Name).getId() = name and

0 commit comments

Comments
 (0)