Skip to content

Commit 8b71b25

Browse files
author
Esben Sparre Andreasen
committed
JS: annotate test file with expected results
1 parent a636319 commit 8b71b25

1 file changed

Lines changed: 65 additions & 65 deletions

File tree

  • javascript/ql/test/query-tests/Expressions/UselessDefensiveProgramming

javascript/ql/test/query-tests/Expressions/UselessDefensiveProgramming/tst.js

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -10,95 +10,95 @@
1010
var o_ = o;
1111
var x_ = x;
1212

13-
u_ = u_ || e;
14-
n_ = n_ || e;
15-
o_ = o_ || e;
13+
u_ = u_ || e; // NOT OK
14+
n_ = n_ || e; // NOT OK
15+
o_ = o_ || e; // NOT OK
1616
x_ = x_ || e;
1717

18-
u && u.p;
19-
n && n.p;
20-
o && o.p;
18+
u && u.p; // NOT OK
19+
n && n.p; // NOT OK
20+
o && o.p; // NOT OK
2121
x && x.p;
2222

23-
u && u();
24-
n && n();
25-
o && o();
23+
u && u(); // NOT OK
24+
n && n(); // NOT OK
25+
o && o(); // NOT OK
2626
x && x();
2727

28-
!u || u.p;
29-
!n || n.p;
30-
!o || o.p;
28+
!u || u.p; // NOT OK
29+
!n || n.p; // NOT OK
30+
!o || o.p; // NOT OK
3131
!x || x.p;
3232

33-
!!u && u.p;
34-
!!n && n.p;
35-
!!o && o.p;
33+
!!u && u.p; // NOT OK
34+
!!n && n.p; // NOT OK
35+
!!o && o.p; // NOT OK
3636
!!x && x.p;
3737

38-
u != undefined && u.p;
39-
n != undefined && n.p;
40-
o != undefined && o.p;
38+
u != undefined && u.p; // NOT OK
39+
n != undefined && n.p; // NOT OK
40+
o != undefined && o.p; // NOT OK
4141
x != undefined && x.p;
4242

43-
u == undefined || u.p;
44-
n == undefined || n.p;
45-
o == undefined || o.p;
43+
u == undefined || u.p; // NOT OK
44+
n == undefined || n.p; // NOT OK
45+
o == undefined || o.p; // NOT OK
4646
x == undefined || x.p;
4747

48-
u === undefined || u.p;
49-
n === undefined || n.p;
50-
o === undefined || o.p; // T, D
48+
u === undefined || u.p; // NOT OK
49+
n === undefined || n.p; // NOT OK
50+
o === undefined || o.p; // NOT OK
5151
x === undefined || x.p;
5252

53-
if (u) {
53+
if (u) { // NOT OK
5454
u.p;
5555
}
56-
if (n) {
56+
if (n) { // NOT OK
5757
n.p;
5858
}
59-
if (o) {
59+
if (o) { // NOT OK
6060
o.p;
6161
}
6262
if (x) {
6363
x.p;
6464
}
6565

66-
u? u():_;
67-
n? n(): _;
68-
o? o(): _;
66+
u? u():_; // NOT OK
67+
n? n(): _; // NOT OK
68+
o? o(): _; // NOT OK
6969
x? x(): _;
7070

71-
if (u !== undefined) {
71+
if (u !== undefined) { // NOT OK
7272
u.p;
7373
}
74-
if (n !== undefined) {
74+
if (n !== undefined) { // NOT OK
7575
n.p;
7676
}
77-
if (o !== undefined) {
77+
if (o !== undefined) { // NOT OK
7878
o.p;
7979
}
8080
if (x !== undefined) {
8181
x.p;
8282
}
8383

84-
if (u == undefined){}
85-
if (n == undefined){}
86-
if (o == undefined){}
84+
if (u == undefined){} // NOT OK
85+
if (n == undefined){} // NOT OK
86+
if (o == undefined){} // NOT OK
8787
if (x == undefined){}
8888

89-
if (u != undefined){}
90-
if (n != undefined){}
91-
if (o != undefined){}
89+
if (u != undefined){} // NOT OK
90+
if (n != undefined){} // NOT OK
91+
if (o != undefined){} // NOT OK
9292
if (x != undefined){}
9393

94-
if (typeof u === "undefined"){}
95-
if (typeof n === "undefined"){}
96-
if (typeof o === "undefined"){}
94+
if (typeof u === "undefined"){} // NOT OK
95+
if (typeof n === "undefined"){} // NOT OK
96+
if (typeof o === "undefined"){} // NOT OK
9797
if (typeof x === "undefined"){}
9898

9999
function f() { }
100-
typeof f === "function" && f();
101-
typeof u === "function" && u();
100+
typeof f === "function" && f(); // NOT OK
101+
typeof u === "function" && u(); // NOT OK
102102
typeof x === "function" && x();
103103

104104
var empty_array = [];
@@ -111,33 +111,33 @@
111111
var _true = true;
112112
var _false = false;
113113

114-
empty_array && empty_array.pop();
115-
pseudo_empty_array && pseudo_empty_array.pop();
116-
non_empty_array && non_empty_array.pop();
114+
empty_array && empty_array.pop(); // NOT OK
115+
pseudo_empty_array && pseudo_empty_array.pop(); // NOT OK
116+
non_empty_array && non_empty_array.pop(); // NOT OK
117117
empty_string && empty_string.charAt(0);
118118
non_empty_string && non_empty_string.charAt(0);
119119
zero && zero();
120120
neg && neg();
121121
_true && _true();
122-
_false && _false();D
123-
124-
(u !== undefined && u !== null) && u.p;
125-
u !== undefined && u !== null && u.p;
126-
127-
u != undefined && u != null;
128-
u == undefined || u == null;
129-
u !== undefined && u !== null;
130-
!(u === undefined) && !(u === null);
131-
u === undefined || u === null;
132-
!(u === undefined || u === null);
133-
!(u === undefined) && u !== null;
122+
_false && _false();
123+
124+
(u !== undefined && u !== null) && u.p; // NOT OK
125+
u !== undefined && u !== null && u.p; // NOT OK
126+
127+
u != undefined && u != null; // NOT OK
128+
u == undefined || u == null; // NOT OK
129+
u !== undefined && u !== null; // NOT OK
130+
!(u === undefined) && !(u === null); // NOT OK
131+
u === undefined || u === null; // NOT OK
132+
!(u === undefined || u === null); // NOT OK
133+
!(u === undefined) && u !== null; // NOT OK
134134
u !== undefined && n !== null;
135-
u == undefined && u == null;
135+
u == undefined && u == null; // NOT OK
136136
x == undefined && x == null;
137137

138-
x === undefined && x === null;
138+
x === undefined && x === null; // NOT OK
139139
if (x === undefined) {
140-
if (x === null) {
140+
if (x === null) { // NOT OK
141141
}
142142
}
143143

@@ -153,16 +153,16 @@
153153
}
154154
}
155155

156-
x != undefined && x != null;
156+
x != undefined && x != null; // NOT OK
157157
if (x != undefined) {
158-
if (x != null) {
158+
if (x != null) { // NOT OK
159159
}
160160
}
161161

162162
if (typeof x !== undefined);
163163
if (typeof window !== undefined);
164164
if (typeof x !== x);
165-
if (typeof x !== u);
165+
if (typeof x !== u); // NOT OK
166166

167167
if (typeof window !== "undefined");
168168
if (typeof module !== "undefined");

0 commit comments

Comments
 (0)