Skip to content

Commit b4df037

Browse files
committed
JS: Ignore obvious Array.prototype.concat calls
1 parent bf2c944 commit b4df037

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

javascript/ql/src/semmle/javascript/StringConcatenation.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ module StringConcatenation {
5555
exists(DataFlow::MethodCallNode call |
5656
node = call and
5757
call.getMethodName() = "concat" and
58+
not (
59+
exists(DataFlow::ArrayCreationNode array |
60+
array.flowsTo(call.getAnArgument()) or array.flowsTo(call.getReceiver())
61+
)
62+
or
63+
DataFlow::reflectiveCallNode(_) = call
64+
) and
5865
(
5966
n = 0 and
6067
result = call.getReceiver()

javascript/ql/test/library-tests/StringConcatenation/tst.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,7 @@ function concatCall() {
9595
x = x.concat('two', 'three');
9696
return x;
9797
}
98+
99+
function arrayConcat(a, b) {
100+
return [].concat(a, b);
101+
}

0 commit comments

Comments
 (0)