forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop.js
More file actions
40 lines (33 loc) · 1.14 KB
/
loop.js
File metadata and controls
40 lines (33 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function increasing(start, end) {
for (var i = start; i < end; ++i) {
if (i >= start) {} // NOT OK - always true
if (i < start) {} // NOT OK - always false
if (i < end) {} // NOT OK - always true
if (i >= end) {} // NOT OK - always false
if (i + 1 > start) {} // NOT OK - always true
if (i - 1 < start) {} // OK
}
}
function decreasing(start, end) {
for (var i = start; i > end; --i) {
if (i <= start) {} // NOT OK - always true
if (i > start) {} // NOT OK - always false
if (i + 1 > start) {} // OK
if (i - 1 < start) {} // NOT OK - always true
}
}
function middleIncrement(start, end) {
for (var i = start; i < end;) {
if (i >= start) {} // OK - always true but we don't catch it
if (i < start) {} // OK - always false but we don't catch it
if (i < end) {} // NOT OK - always true
if (i >= end) {} // NOT OK - always false
if (something()) {
i += 2;
}
if (i >= start) {} // OK - always true but we don't catch it
if (i < start) {} // OK - always false but we don't catch it
if (i < end) {} // OK
if (i >= end) {} // OK
}
}