mirror of
https://github.com/github/codeql.git
synced 2026-05-04 21:25:44 +02:00
fix FP in superfluous-trailing-arguments related to Function.arguments
This commit is contained in:
@@ -117,7 +117,13 @@ class Function extends @function, Parameterized, TypeParameterized, StmtContaine
|
||||
ArgumentsVariable getArgumentsVariable() { result.getFunction() = this }
|
||||
|
||||
/** Holds if the body of this function refers to the function's `arguments` variable. */
|
||||
predicate usesArgumentsObject() { exists(getArgumentsVariable().getAnAccess()) }
|
||||
predicate usesArgumentsObject() {
|
||||
exists(getArgumentsVariable().getAnAccess()) or
|
||||
exists(PropAccess read |
|
||||
read.getBase() = getVariable().getAnAccess() and
|
||||
read.getPropertyName() = "arguments"
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this function declares a parameter or local variable named `arguments`.
|
||||
|
||||
@@ -120,3 +120,13 @@ parseFloat("123", 10);
|
||||
throwerWithParam(42, 87); // NOT OK
|
||||
throwerIndirect(42); // OK, but still flagged due to complexity
|
||||
});
|
||||
|
||||
function sum2() {
|
||||
var result = 0;
|
||||
for (var i=0,n=sum2.arguments.length; i<n; ++i)
|
||||
result += sum2.arguments[i];
|
||||
return result;
|
||||
}
|
||||
|
||||
// OK
|
||||
sum2(1, 2, 3);
|
||||
Reference in New Issue
Block a user