JS: Ignore obvious Array.prototype.concat calls

This commit is contained in:
Asger Feldthaus
2020-02-04 16:36:41 +00:00
parent bf2c944b4f
commit b4df03767d
2 changed files with 11 additions and 0 deletions

View File

@@ -55,6 +55,13 @@ module StringConcatenation {
exists(DataFlow::MethodCallNode call |
node = call and
call.getMethodName() = "concat" and
not (
exists(DataFlow::ArrayCreationNode array |
array.flowsTo(call.getAnArgument()) or array.flowsTo(call.getReceiver())
)
or
DataFlow::reflectiveCallNode(_) = call
) and
(
n = 0 and
result = call.getReceiver()

View File

@@ -95,3 +95,7 @@ function concatCall() {
x = x.concat('two', 'three');
return x;
}
function arrayConcat(a, b) {
return [].concat(a, b);
}