Skip to content

Commit bf3d9ee

Browse files
committed
Python: Address review comments
1 parent 83cdcdb commit bf3d9ee

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

python/ql/lib/semmle/python/Function.qll

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,18 @@ class Function extends Function_, Scope, AstNode {
165165
}
166166

167167
/** Gets the minimum number of positional arguments that can be correctly passed to this function. */
168-
int getMinArguments() {
168+
int getMinPositionalArguments() {
169169
result = count(this.getAnArg()) - count(this.getDefinition().getArgs().getADefault())
170170
}
171171

172-
/** Gets the maximum number of positional arguments that can be correctly passed to this function. */
173-
int getMaxArguments() {
172+
/**
173+
* Gets the maximum number of positional arguments that can be correctly passed to this function.
174+
*
175+
* If the function has a `*vararg` parameter, there is no upper limit on the number of positional
176+
* arguments that can be passed to the function. In this case, this method returns a very large
177+
* number (currently `INT_MAX`, 2147483647, but this may change in the future).
178+
*/
179+
int getMaxPositionalArguments() {
174180
if exists(this.getVararg())
175181
then result = 2147483647 // INT_MAX
176182
else result = count(this.getAnArg())

python/ql/lib/semmle/python/objects/ObjectAPI.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,9 +738,9 @@ class PythonFunctionValue extends FunctionValue {
738738
else result = "function " + this.getQualifiedName()
739739
}
740740

741-
override int minParameters() { result = this.getScope().getMinArguments() }
741+
override int minParameters() { result = this.getScope().getMinPositionalArguments() }
742742

743-
override int maxParameters() { result = this.getScope().getMaxArguments() }
743+
override int maxParameters() { result = this.getScope().getMaxPositionalArguments() }
744744

745745
/** Gets a control flow node corresponding to a return statement in this function */
746746
ControlFlowNode getAReturnedNode() { result = this.getScope().getAReturnValueFlowNode() }

0 commit comments

Comments
 (0)