mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
JS: Add UselessRangeCheck.ql
This commit is contained in:
@@ -0,0 +1 @@
|
||||
| example.js:8:7:8:13 | i < end | The condition 'i < end' is always false |
|
||||
@@ -0,0 +1 @@
|
||||
Statements/UselessRangeCheck.ql
|
||||
@@ -0,0 +1,12 @@
|
||||
function findValue(values, x, start, end) {
|
||||
let i;
|
||||
for (i = start; i < end; ++i) {
|
||||
if (values[i] === x) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
if (i < end) {
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
function findValue(values, x, start, end) {
|
||||
for (let i = start; i < end; ++i) {
|
||||
if (values[i] === x) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
Reference in New Issue
Block a user