Skip to content

Commit a28fc8e

Browse files
committed
JS: Add: Use of returnless function support for findLast and findLastIndex
1 parent 7250099 commit a28fc8e

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

javascript/ql/src/Statements/UseOfReturnlessFunction.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ predicate hasNonVoidCallbackMethod(string name) {
114114
name =
115115
[
116116
"every", "filter", "find", "findIndex", "flatMap", "map", "reduce", "reduceRight", "some",
117-
"sort"
117+
"sort", "findLastIndex", "findLast"
118118
]
119119
}
120120

javascript/ql/test/query-tests/Statements/UseOfReturnlessFunction/UseOfReturnlessFunction.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
| tst.js:53:10:53:34 | bothOnl ... fects() | the $@ does not return anything, yet the return value is used. | tst.js:48:2:50:5 | functio ... )\\n } | function onlySideEffects2 |
88
| tst.js:76:12:76:46 | [1,2,3] ... n, 3)}) | the $@ does not return anything, yet the return value from the call to filter is used. | tst.js:76:27:76:45 | n => {equals(n, 3)} | callback function |
99
| tst.js:80:12:80:50 | filter( ... 3) } ) | the $@ does not return anything, yet the return value from the call to filter is used. | tst.js:80:28:80:48 | x => { ... x, 3) } | callback function |
10+
| tst.js:114:12:114:56 | [1,2,3] ... 3); }) | the $@ does not return anything, yet the return value from the call to findLastIndex is used. | tst.js:114:34:114:55 | n => { ... , 3); } | callback function |
11+
| tst.js:117:12:117:51 | [1,2,3] ... 3); }) | the $@ does not return anything, yet the return value from the call to findLast is used. | tst.js:117:29:117:50 | n => { ... , 3); } | callback function |

javascript/ql/test/query-tests/Statements/UseOfReturnlessFunction/tst.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ class Bar extends Foo {
111111
() => {
112112
let equals = (x, y) => { return x === y; };
113113

114-
var foo = [1,2,3].findLastIndex(n => { equals(n, 3); }) // NOT OK -- Currently not flagged, but should be.
114+
var foo = [1,2,3].findLastIndex(n => { equals(n, 3); }) // NOT OK
115115
console.log(foo);
116116

117-
var foo = [1,2,3].findLast(n => { equals(n, 3); }) // NOT OK -- Currently not flagged, but should be.
117+
var foo = [1,2,3].findLast(n => { equals(n, 3); }) // NOT OK
118118
console.log(foo);
119119
}

0 commit comments

Comments
 (0)