fix FP in superfluous-trailing-arguments related to Function.arguments

This commit is contained in:
Erik Krogh Kristensen
2020-03-23 10:40:35 +01:00
parent 888c504f55
commit 2c43d1d731
2 changed files with 17 additions and 1 deletions

View File

@@ -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`.

View File

@@ -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);