// OK
+
}
diff --git a/javascript/ql/test/query-tests/Expressions/UnclearOperatorPrecedence/UnclearOperatorPrecedence.qlref b/javascript/ql/test/query-tests/Expressions/UnclearOperatorPrecedence/UnclearOperatorPrecedence.qlref
index 5a9a25e11186..d4887864cb1d 100644
--- a/javascript/ql/test/query-tests/Expressions/UnclearOperatorPrecedence/UnclearOperatorPrecedence.qlref
+++ b/javascript/ql/test/query-tests/Expressions/UnclearOperatorPrecedence/UnclearOperatorPrecedence.qlref
@@ -1 +1,2 @@
-Expressions/UnclearOperatorPrecedence.ql
\ No newline at end of file
+query: Expressions/UnclearOperatorPrecedence.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/Expressions/UnclearOperatorPrecedence/tst.js b/javascript/ql/test/query-tests/Expressions/UnclearOperatorPrecedence/tst.js
index 5490b0b4232a..9aa369d69b21 100644
--- a/javascript/ql/test/query-tests/Expressions/UnclearOperatorPrecedence/tst.js
+++ b/javascript/ql/test/query-tests/Expressions/UnclearOperatorPrecedence/tst.js
@@ -1,10 +1,10 @@
-x.f() & 0x0A != 0; // NOT OK
-x.f() & (0x0A != 0); // OK
-x.f() & 0x0A != 0; // OK
-x.f() & 0x0A!=0; // OK
+x.f() & 0x0A != 0; // $ Alert
+x.f() & (0x0A != 0);
+x.f() & 0x0A != 0;
+x.f() & 0x0A!=0;
-x !== y & 1; // NOT OK
+x !== y & 1; // $ Alert
-x > 0 & x < 10; // OK
+x > 0 & x < 10;
-a&b==c; // NOT OK
+a&b==c; // $ Alert
diff --git a/javascript/ql/test/query-tests/Expressions/UnclearOperatorPrecedence/tst.min.js b/javascript/ql/test/query-tests/Expressions/UnclearOperatorPrecedence/tst.min.js
index 800b7b08df2c..d39838870c81 100644
--- a/javascript/ql/test/query-tests/Expressions/UnclearOperatorPrecedence/tst.min.js
+++ b/javascript/ql/test/query-tests/Expressions/UnclearOperatorPrecedence/tst.min.js
@@ -1 +1 @@
-a&b==c; // OK (minified file)
+a&b==c; // OK - minified file
diff --git a/javascript/ql/test/query-tests/Expressions/UnknownDirective/UnknownDirective.html b/javascript/ql/test/query-tests/Expressions/UnknownDirective/UnknownDirective.html
index 87f969c3e179..03ac0651186e 100644
--- a/javascript/ql/test/query-tests/Expressions/UnknownDirective/UnknownDirective.html
+++ b/javascript/ql/test/query-tests/Expressions/UnknownDirective/UnknownDirective.html
@@ -1,6 +1,6 @@
-
-
-
+
+
+
diff --git a/javascript/ql/test/query-tests/Expressions/UnknownDirective/UnknownDirective.js b/javascript/ql/test/query-tests/Expressions/UnknownDirective/UnknownDirective.js
index 0645f8821a1d..e86b7b9d95bc 100644
--- a/javascript/ql/test/query-tests/Expressions/UnknownDirective/UnknownDirective.js
+++ b/javascript/ql/test/query-tests/Expressions/UnknownDirective/UnknownDirective.js
@@ -1,51 +1,51 @@
-"use foo"; // NOT OK
-"use strict"; // NOT OK
+"use foo"; // $ Alert
+"use strict";
function bad() {
- "'use strict'"; // NOT OK
- "use strict;"; // NOT OK
- "'use strict';"; // NOT OK
- "'use strict;'"; // NOT OK
- "use-strict"; // NOT OK
- "use_strict"; // NOT OK
- "uses strict"; // NOT OK
- "use struct;" // NOT OK
- "Use Strict"; // NOT OK
- "use bar"; // NOT OK
+ "'use strict'"; // $ Alert
+ "use strict;"; // $ Alert
+ "'use strict';"; // $ Alert
+ "'use strict;'"; // $ Alert
+ "use-strict"; // $ Alert
+ "use_strict"; // $ Alert
+ "uses strict"; // $ Alert
+ "use struct;" // $ Alert
+ "Use Strict"; // $ Alert
+ "use bar"; // $ Alert
}
function ignored() {
var x = 42;
- "use baz"; // OK: not a directive, positionally
+ "use baz"; // OK - not a directive, positionally
}
function good() {
- "use strict"; // OK
- "use asm"; // OK
- "use babel"; // OK
- "use 6to5"; // OK
- "format cjs" // OK
- "format esm"; // OK
- "format global"; // OK
- "format register"; // OK
- "ngInject"; // OK
- "ngNoInject"; // OK
- "deps foo"; // OK
- "deps bar"; // OK
- "use server"; // OK
- "use client"; // OK
+ "use strict";
+ "use asm";
+ "use babel";
+ "use 6to5";
+ "format cjs"
+ "format esm";
+ "format global";
+ "format register";
+ "ngInject";
+ "ngNoInject";
+ "deps foo";
+ "deps bar";
+ "use server";
+ "use client";
}
function data() {
- "[0, 0, 0];"; // NOT OK
- "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];"; // NOT OK
+ "[0, 0, 0];"; // $ Alert
+ "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];"; // $ Alert
}
function yui() {
- "foo:nomunge"; // OK
- "bar:nomunge, baz:nomunge,qux:nomunge"; // OK
- ":nomunge"; // NOT OK
- "foo(), bar, baz:nomunge"; // NOT OK
+ "foo:nomunge";
+ "bar:nomunge, baz:nomunge,qux:nomunge";
+ ":nomunge"; // $ Alert
+ "foo(), bar, baz:nomunge"; // $ Alert
}
function babel_typeof(obj) {
diff --git a/javascript/ql/test/query-tests/Expressions/UnknownDirective/UnknownDirective.qlref b/javascript/ql/test/query-tests/Expressions/UnknownDirective/UnknownDirective.qlref
index 2cd60100c59e..0fa5fe40535d 100644
--- a/javascript/ql/test/query-tests/Expressions/UnknownDirective/UnknownDirective.qlref
+++ b/javascript/ql/test/query-tests/Expressions/UnknownDirective/UnknownDirective.qlref
@@ -1 +1,2 @@
-Expressions/UnknownDirective.ql
\ No newline at end of file
+query: Expressions/UnknownDirective.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/HeterogeneousComparison.qlref b/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/HeterogeneousComparison.qlref
index 13b0e2a181cb..22ce4796bb35 100644
--- a/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/HeterogeneousComparison.qlref
+++ b/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/HeterogeneousComparison.qlref
@@ -1 +1,2 @@
-Expressions/HeterogeneousComparison.ql
\ No newline at end of file
+query: Expressions/HeterogeneousComparison.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/UnneededDefensiveProgramming.qlref b/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/UnneededDefensiveProgramming.qlref
index 13c05f1e74bd..98fc974827b4 100644
--- a/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/UnneededDefensiveProgramming.qlref
+++ b/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/UnneededDefensiveProgramming.qlref
@@ -1 +1,2 @@
-Expressions/UnneededDefensiveProgramming.ql
+query: Expressions/UnneededDefensiveProgramming.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/UselessConditional.qlref b/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/UselessConditional.qlref
index d29916245d6e..85ffff223221 100644
--- a/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/UselessConditional.qlref
+++ b/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/UselessConditional.qlref
@@ -1 +1,2 @@
-Statements/UselessConditional.ql
\ No newline at end of file
+query: Statements/UselessConditional.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/global-module-definition.js b/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/global-module-definition.js
index 8c61f38d1132..99e77e8cc491 100644
--- a/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/global-module-definition.js
+++ b/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/global-module-definition.js
@@ -7,5 +7,5 @@ var Mod1;
var Mod2;
(function (Mod2) {
Mod2.p = 42;
- })(Mod2 || (Mod2 = {})); // NOT OK
+ })(Mod2 || (Mod2 = {}));
});
diff --git a/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/module-environment-detection.js b/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/module-environment-detection.js
index 913684d6f6aa..1de67b231fa8 100644
--- a/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/module-environment-detection.js
+++ b/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/module-environment-detection.js
@@ -20,5 +20,5 @@ if (typeof exports !== 'undefined') {
(function(){
var module;
- if(typeof module === 'undefined'); // NOT OK
+ if(typeof module === 'undefined'); // $ Alert[js/unneeded-defensive-code]
});
diff --git a/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/regression.js b/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/regression.js
index cfc6f1e6df71..adf17a8b3fd0 100644
--- a/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/regression.js
+++ b/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/regression.js
@@ -6,10 +6,10 @@ function getDate() {
return null;
}
console.log(date);
- return date && date.getTime(); // NOT OK
+ return date && date.getTime(); // $ Alert[js/unneeded-defensive-code]
}
function isNotNullOrString(obj) {
- return obj != null && obj != undefined && // NOT OK
- typeof obj != 'string';
+ return obj != null && obj != undefined && // $ Alert[js/unneeded-defensive-code]
+ typeof obj != 'string';
}
diff --git a/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/tst.js b/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/tst.js
index ace5a3dd7ac8..7b4a4b799e06 100644
--- a/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/tst.js
+++ b/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/tst.js
@@ -10,95 +10,95 @@
var o_ = o;
var x_ = x;
- u_ = u_ || e; // NOT OK
- n_ = n_ || e; // NOT OK
- o_ = o_ || e; // NOT OK
+ u_ = u_ || e; // $ MISSING: Alert[js/unneeded-defensive-code]
+ n_ = n_ || e; // $ MISSING: Alert[js/unneeded-defensive-code]
+ o_ = o_ || e; // $ MISSING: Alert[js/unneeded-defensive-code]
x_ = x_ || e;
- u && u.p; // NOT OK
- n && n.p; // NOT OK
- o && o.p; // NOT OK
+ u && u.p; // $ Alert[js/unneeded-defensive-code]
+ n && n.p; // $ Alert[js/unneeded-defensive-code]
+ o && o.p; // $ Alert[js/unneeded-defensive-code]
x && x.p;
- u && u(); // NOT OK
- n && n(); // NOT OK
- o && o(); // NOT OK
+ u && u(); // $ Alert[js/unneeded-defensive-code]
+ n && n(); // $ Alert[js/unneeded-defensive-code]
+ o && o(); // $ Alert[js/unneeded-defensive-code]
x && x();
- !u || u.p; // NOT OK
- !n || n.p; // NOT OK
- !o || o.p; // NOT OK
+ !u || u.p; // $ Alert[js/unneeded-defensive-code]
+ !n || n.p; // $ Alert[js/unneeded-defensive-code]
+ !o || o.p; // $ Alert[js/unneeded-defensive-code]
!x || x.p;
- !!u && u.p; // NOT OK
- !!n && n.p; // NOT OK
- !!o && o.p; // NOT OK
+ !!u && u.p; // $ Alert[js/unneeded-defensive-code]
+ !!n && n.p; // $ Alert[js/unneeded-defensive-code]
+ !!o && o.p; // $ Alert[js/unneeded-defensive-code]
!!x && x.p;
- u != undefined && u.p; // NOT OK
- n != undefined && n.p; // NOT OK
- o != undefined && o.p; // NOT OK
+ u != undefined && u.p; // $ Alert[js/unneeded-defensive-code]
+ n != undefined && n.p; // $ Alert[js/unneeded-defensive-code]
+ o != undefined && o.p; // $ Alert[js/unneeded-defensive-code]
x != undefined && x.p;
- u == undefined || u.p; // NOT OK
- n == undefined || n.p; // NOT OK
- o == undefined || o.p; // NOT OK
+ u == undefined || u.p; // $ Alert[js/unneeded-defensive-code]
+ n == undefined || n.p; // $ Alert[js/unneeded-defensive-code]
+ o == undefined || o.p; // $ Alert[js/unneeded-defensive-code]
x == undefined || x.p;
- u === undefined || u.p; // NOT OK
- n === undefined || n.p; // NOT OK
- o === undefined || o.p; // NOT OK
+ u === undefined || u.p; // $ Alert[js/unneeded-defensive-code]
+ n === undefined || n.p; // $ Alert[js/unneeded-defensive-code]
+ o === undefined || o.p; // $ Alert[js/unneeded-defensive-code]
x === undefined || x.p;
- if (u) { // NOT OK
+ if (u) { // $ Alert[js/unneeded-defensive-code]
u.p;
}
- if (n) { // NOT OK
+ if (n) { // $ Alert[js/unneeded-defensive-code]
n.p;
}
- if (o) { // NOT OK
+ if (o) { // $ Alert[js/unneeded-defensive-code]
o.p;
}
if (x) {
x.p;
}
- u? u():_; // NOT OK
- n? n(): _; // NOT OK
- o? o(): _; // NOT OK
+ u? u():_; // $ Alert[js/unneeded-defensive-code]
+ n? n(): _; // $ Alert[js/unneeded-defensive-code]
+ o? o(): _; // $ Alert[js/unneeded-defensive-code]
x? x(): _;
- if (u !== undefined) { // NOT OK
+ if (u !== undefined) { // $ Alert[js/unneeded-defensive-code]
u.p;
}
- if (n !== undefined) { // NOT OK
+ if (n !== undefined) { // $ Alert[js/unneeded-defensive-code]
n.p;
}
- if (o !== undefined) { // NOT OK
+ if (o !== undefined) { // $ Alert[js/unneeded-defensive-code]
o.p;
}
if (x !== undefined) {
x.p;
}
- if (u == undefined){} // NOT OK
- if (n == undefined){} // NOT OK
- if (o == undefined){} // NOT OK
+ if (u == undefined){} // $ Alert[js/unneeded-defensive-code]
+ if (n == undefined){} // $ Alert[js/unneeded-defensive-code]
+ if (o == undefined){} // $ Alert[js/unneeded-defensive-code]
if (x == undefined){}
- if (u != undefined){} // NOT OK
- if (n != undefined){} // NOT OK
- if (o != undefined){} // NOT OK
+ if (u != undefined){} // $ Alert[js/unneeded-defensive-code]
+ if (n != undefined){} // $ Alert[js/unneeded-defensive-code]
+ if (o != undefined){} // $ Alert[js/unneeded-defensive-code]
if (x != undefined){}
- if (typeof u === "undefined"){} // NOT OK
- if (typeof n === "undefined"){} // NOT OK
- if (typeof o === "undefined"){} // NOT OK
+ if (typeof u === "undefined"){} // $ Alert[js/unneeded-defensive-code]
+ if (typeof n === "undefined"){} // $ Alert[js/unneeded-defensive-code]
+ if (typeof o === "undefined"){} // $ Alert[js/unneeded-defensive-code]
if (typeof x === "undefined"){}
function f() { }
- typeof f === "function" && f(); // NOT OK
- typeof u === "function" && u(); // NOT OK
+ typeof f === "function" && f(); // $ Alert[js/unneeded-defensive-code]
+ typeof u === "function" && u(); // $ Alert[js/unneeded-defensive-code]
typeof x === "function" && x();
var empty_array = [];
@@ -111,9 +111,9 @@
var _true = true;
var _false = false;
- empty_array && empty_array.pop(); // NOT OK
- pseudo_empty_array && pseudo_empty_array.pop(); // NOT OK
- non_empty_array && non_empty_array.pop(); // NOT OK
+ empty_array && empty_array.pop(); // $ Alert[js/unneeded-defensive-code]
+ pseudo_empty_array && pseudo_empty_array.pop(); // $ Alert[js/unneeded-defensive-code]
+ non_empty_array && non_empty_array.pop(); // $ Alert[js/unneeded-defensive-code]
empty_string && empty_string.charAt(0);
non_empty_string && non_empty_string.charAt(0);
zero && zero();
@@ -121,23 +121,23 @@
_true && _true();
_false && _false();
- (u !== undefined && u !== null) && u.p; // NOT OK
- u !== undefined && u !== null && u.p; // NOT OK
+ (u !== undefined && u !== null) && u.p; // $ Alert[js/unneeded-defensive-code]
+ u !== undefined && u !== null && u.p; // $ Alert[js/unneeded-defensive-code]
- u != undefined && u != null; // NOT OK
- u == undefined || u == null; // NOT OK
- u !== undefined && u !== null; // NOT OK
- !(u === undefined) && !(u === null); // NOT OK
- u === undefined || u === null; // NOT OK
- !(u === undefined || u === null); // NOT OK
- !(u === undefined) && u !== null; // NOT OK
+ u != undefined && u != null; // $ Alert[js/unneeded-defensive-code]
+ u == undefined || u == null; // $ Alert[js/unneeded-defensive-code]
+ u !== undefined && u !== null; // $ Alert[js/unneeded-defensive-code]
+ !(u === undefined) && !(u === null); // $ Alert[js/unneeded-defensive-code]
+ u === undefined || u === null; // $ Alert[js/unneeded-defensive-code]
+ !(u === undefined || u === null); // $ Alert[js/unneeded-defensive-code]
+ !(u === undefined) && u !== null; // $ Alert[js/unneeded-defensive-code]
u !== undefined && n !== null;
- u == undefined && u == null; // NOT OK
+ u == undefined && u == null; // $ Alert[js/unneeded-defensive-code]
x == undefined && x == null;
- x === undefined && x === null; // NOT OK
+ x === undefined && x === null; // $ Alert[js/unneeded-defensive-code]
if (x === undefined) {
- if (x === null) { // NOT OK
+ if (x === null) { // $ Alert[js/unneeded-defensive-code]
}
}
@@ -153,16 +153,16 @@
}
}
- x != undefined && x != null; // NOT OK
+ x != undefined && x != null; // $ Alert[js/unneeded-defensive-code]
if (x != undefined) {
- if (x != null) { // NOT OK
+ if (x != null) { // $ Alert[js/unneeded-defensive-code]
}
}
- if (typeof x !== undefined);
- if (typeof window !== undefined);
+ if (typeof x !== undefined); // $ Alert[js/comparison-between-incompatible-types]
+ if (typeof window !== undefined); // $ Alert[js/comparison-between-incompatible-types]
if (typeof x !== x);
- if (typeof x !== u); // NOT OK
+ if (typeof x !== u); // $ Alert[js/comparison-between-incompatible-types]
if (typeof window !== "undefined");
if (typeof module !== "undefined");
@@ -172,12 +172,12 @@
if (typeof module !== "undefined" && module.exports);
if (typeof global !== "undefined" && global.process);
- u && (f(), u.p);
- u && (u.p, f()); // technically not OK, but it seems like an unlikely pattern
- u && !u.p; // NOT OK
- u && !u(); // NOT OK
+ u && (f(), u.p); // $ Alert[js/trivial-conditional]
+ u && (u.p, f()); // $ Alert[js/trivial-conditional] - technically not OK, but it seems like an unlikely pattern
+ u && !u.p; // $ Alert[js/unneeded-defensive-code]
+ u && !u(); // $ Alert[js/unneeded-defensive-code]
+
-
function hasCallbacks(success, error) {
if (success) success()
if (error) error()
diff --git a/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/tst2.js b/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/tst2.js
index 588844f9c75f..eb0dee8c535e 100644
--- a/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/tst2.js
+++ b/javascript/ql/test/query-tests/Expressions/UnneededDefensiveProgramming/tst2.js
@@ -1,7 +1,7 @@
(function(){
var v;
(function(){
- if(typeof v === "undefined"){ // NOT OK
+ if(typeof v === "undefined"){ // $ Alert[js/unneeded-defensive-code]
v = 42;
}
for(var v in x){
@@ -9,10 +9,10 @@
});
});
-const isFalsyObject = (v) => typeof v === 'undefined' && v !== undefined; // OK
+const isFalsyObject = (v) => typeof v === 'undefined' && v !== undefined;
function f(v) {
- if (typeof v === 'undefined' && v !== undefined) { // OK
+ if (typeof v === 'undefined' && v !== undefined) {
doSomething(v);
}
}
diff --git a/javascript/ql/test/query-tests/Expressions/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.expected b/javascript/ql/test/query-tests/Expressions/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.expected
index 81cd1fac8fd5..82d959bca090 100644
--- a/javascript/ql/test/query-tests/Expressions/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.expected
+++ b/javascript/ql/test/query-tests/Expressions/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.expected
@@ -1,3 +1,3 @@
| tst.js:2:9:2:16 | x + x>>1 | Whitespace around nested operators contradicts precedence. |
| tst.js:42:9:42:20 | p in o&&o[p] | Whitespace around nested operators contradicts precedence. |
-| tst.js:49:1:49:12 | x + x >> 1 | Whitespace around nested operators contradicts precedence. |
+| tst.js:48:1:48:12 | x + x >> 1 | Whitespace around nested operators contradicts precedence. |
diff --git a/javascript/ql/test/query-tests/Expressions/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.qlref b/javascript/ql/test/query-tests/Expressions/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.qlref
index 4905e880b56a..b1d60a5feea0 100644
--- a/javascript/ql/test/query-tests/Expressions/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.qlref
+++ b/javascript/ql/test/query-tests/Expressions/WhitespaceContradictsPrecedence/WhitespaceContradictsPrecedence.qlref
@@ -1 +1,2 @@
-Expressions/WhitespaceContradictsPrecedence.ql
\ No newline at end of file
+query: Expressions/WhitespaceContradictsPrecedence.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/Expressions/WhitespaceContradictsPrecedence/tst.js b/javascript/ql/test/query-tests/Expressions/WhitespaceContradictsPrecedence/tst.js
index d9942a5ec4a8..30b75270f946 100644
--- a/javascript/ql/test/query-tests/Expressions/WhitespaceContradictsPrecedence/tst.js
+++ b/javascript/ql/test/query-tests/Expressions/WhitespaceContradictsPrecedence/tst.js
@@ -1,35 +1,35 @@
function bad(x) {
- return x + x>>1;
+ return x + x>>1; // $ Alert
}
function ok1(x) {
- return x + x >> 1;
+ return x + x >> 1;
}
function ok2(x) {
- return x+x >> 1;
+ return x+x >> 1;
}
function ok3(x) {
- return x + (x>>1);
+ return x + (x>>1);
}
function ok4(x, y, z) {
return x + y + z;
}
-
+
function ok5(x, y, z) {
return x + y+z;
}
function ok6(x) {
- return x + x>> 1;
+ return x + x>> 1;
}
function ok7(x, y, z) {
return x + y - z;
}
-
+
function ok8(x, y, z) {
return x + y-z;
}
@@ -38,18 +38,17 @@ function ok9(x, y, z) {
return x * y*z;
}
-function ok10(o, p) {
- return p in o&&o[p];
+function bad10(o, p) {
+ return p in o&&o[p]; // $ Alert
}
-// OK
+
x==y ** 2;
-// NOT OK
-x + x >> 1
+x + x >> 1 // $ Alert
+
-// OK
x + x >> 1
-// OK (asm.js-like)
-x = x - 1|0;
\ No newline at end of file
+// OK - asm.js-like
+x = x - 1|0;
diff --git a/javascript/ql/test/query-tests/JSDoc/BadParamTag/BadParamTag.qlref b/javascript/ql/test/query-tests/JSDoc/BadParamTag/BadParamTag.qlref
index 13e42724d606..478f17148e10 100644
--- a/javascript/ql/test/query-tests/JSDoc/BadParamTag/BadParamTag.qlref
+++ b/javascript/ql/test/query-tests/JSDoc/BadParamTag/BadParamTag.qlref
@@ -1 +1 @@
-JSDoc/BadParamTag.ql
\ No newline at end of file
+query: JSDoc/BadParamTag.ql
diff --git a/javascript/ql/test/query-tests/JSDoc/JSDocForNonExistentParameter/JSDocForNonExistentParameter.qlref b/javascript/ql/test/query-tests/JSDoc/JSDocForNonExistentParameter/JSDocForNonExistentParameter.qlref
index 05473298ac8d..75206f43fafb 100644
--- a/javascript/ql/test/query-tests/JSDoc/JSDocForNonExistentParameter/JSDocForNonExistentParameter.qlref
+++ b/javascript/ql/test/query-tests/JSDoc/JSDocForNonExistentParameter/JSDocForNonExistentParameter.qlref
@@ -1 +1 @@
-JSDoc/JSDocForNonExistentParameter.ql
\ No newline at end of file
+query: JSDoc/JSDocForNonExistentParameter.ql
diff --git a/javascript/ql/test/query-tests/JSDoc/UndocumentedParameter/UndocumentedParameter.expected b/javascript/ql/test/query-tests/JSDoc/UndocumentedParameter/UndocumentedParameter.expected
index 6b028267ff76..4ed958a048a1 100644
--- a/javascript/ql/test/query-tests/JSDoc/UndocumentedParameter/UndocumentedParameter.expected
+++ b/javascript/ql/test/query-tests/JSDoc/UndocumentedParameter/UndocumentedParameter.expected
@@ -1,2 +1,2 @@
-| tst.js:6:15:6:15 | y | Parameter y is not documented. |
-| tst.js:26:19:26:19 | y | Parameter y is not documented. |
+| tst.js:4:15:4:15 | y | Parameter y is not documented. |
+| tst.js:23:19:23:19 | y | Parameter y is not documented. |
diff --git a/javascript/ql/test/query-tests/JSDoc/UndocumentedParameter/UndocumentedParameter.qlref b/javascript/ql/test/query-tests/JSDoc/UndocumentedParameter/UndocumentedParameter.qlref
index 8c3b2613cba3..d6b0343c6c02 100644
--- a/javascript/ql/test/query-tests/JSDoc/UndocumentedParameter/UndocumentedParameter.qlref
+++ b/javascript/ql/test/query-tests/JSDoc/UndocumentedParameter/UndocumentedParameter.qlref
@@ -1 +1,2 @@
-JSDoc/UndocumentedParameter.ql
\ No newline at end of file
+query: JSDoc/UndocumentedParameter.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/JSDoc/UndocumentedParameter/tst.js b/javascript/ql/test/query-tests/JSDoc/UndocumentedParameter/tst.js
index b785e06507a7..6143b7084c3b 100644
--- a/javascript/ql/test/query-tests/JSDoc/UndocumentedParameter/tst.js
+++ b/javascript/ql/test/query-tests/JSDoc/UndocumentedParameter/tst.js
@@ -1,9 +1,7 @@
/**
- * NOT OK: Parameter y is not documented.
- *
* @param x The first operand.
*/
-function f(x, y) {
+function f(x, y) { // $ Alert
return x+y;
}
@@ -14,7 +12,6 @@ function g(x, y) {
return x+y;
}
-// NOT OK
/**
* @param {int} x
* @param {float} y
@@ -23,6 +20,6 @@ var o = {
/**
* @param {String} x first argument.
*/
- f : function(x, y) {
+ f : function(x, y) { // $ Alert
}
};
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/ArgumentsCallerCallee/ArgumentsCallerCallee.qlref b/javascript/ql/test/query-tests/LanguageFeatures/ArgumentsCallerCallee/ArgumentsCallerCallee.qlref
index 6f22e925dbd1..fd66fb21e620 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/ArgumentsCallerCallee/ArgumentsCallerCallee.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/ArgumentsCallerCallee/ArgumentsCallerCallee.qlref
@@ -1 +1,2 @@
-LanguageFeatures/ArgumentsCallerCallee.ql
\ No newline at end of file
+query: LanguageFeatures/ArgumentsCallerCallee.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/ArgumentsCallerCallee/tst.js b/javascript/ql/test/query-tests/LanguageFeatures/ArgumentsCallerCallee/tst.js
index 32b12e606bc6..d988977efdd8 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/ArgumentsCallerCallee/tst.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/ArgumentsCallerCallee/tst.js
@@ -1,7 +1,7 @@
(function (i) {
if (i <= 1)
return 1;
- return i*arguments.callee(i-1);
+ return i*arguments.callee(i-1); // $ Alert
}(3));
function f() {
@@ -9,7 +9,7 @@ function f() {
}
function g() {
- return arguments.caller.length;
+ return arguments.caller.length; // $ Alert
}
function h(arguments) {
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/BadTypeof/BadTypeof.expected b/javascript/ql/test/query-tests/LanguageFeatures/BadTypeof/BadTypeof.expected
index bffe622dc7e0..7be415438250 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/BadTypeof/BadTypeof.expected
+++ b/javascript/ql/test/query-tests/LanguageFeatures/BadTypeof/BadTypeof.expected
@@ -1,3 +1,3 @@
-| tst.js:2:1:2:8 | typeof a | The result of this 'typeof' expression is compared to $@, but the two can never be equal. | tst.js:2:14:2:20 | 'array' | array |
-| tst.js:19:9:19:16 | typeof a | The result of this 'typeof' expression is compared to $@, but the two can never be equal. | tst.js:23:6:23:11 | 'null' | null |
-| tst.js:33:2:33:9 | typeof a | The result of this 'typeof' expression is compared to $@, but the two can never be equal. | tst.js:33:16:33:22 | 'array' | array |
+| tst.js:1:1:1:8 | typeof a | The result of this 'typeof' expression is compared to $@, but the two can never be equal. | tst.js:1:14:1:20 | 'array' | array |
+| tst.js:18:9:18:16 | typeof a | The result of this 'typeof' expression is compared to $@, but the two can never be equal. | tst.js:21:6:21:11 | 'null' | null |
+| tst.js:30:2:30:9 | typeof a | The result of this 'typeof' expression is compared to $@, but the two can never be equal. | tst.js:30:16:30:22 | 'array' | array |
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/BadTypeof/BadTypeof.qlref b/javascript/ql/test/query-tests/LanguageFeatures/BadTypeof/BadTypeof.qlref
index ebbb3c84a1e5..9ed7fa52f7cc 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/BadTypeof/BadTypeof.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/BadTypeof/BadTypeof.qlref
@@ -1 +1,2 @@
-LanguageFeatures/BadTypeof.ql
\ No newline at end of file
+query: LanguageFeatures/BadTypeof.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/BadTypeof/tst.js b/javascript/ql/test/query-tests/LanguageFeatures/BadTypeof/tst.js
index de01c66ac808..9401c80cba52 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/BadTypeof/tst.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/BadTypeof/tst.js
@@ -1,36 +1,33 @@
-// NOT OK
-typeof a === 'array';
+typeof a === 'array'; // $ Alert
+
-// OK
typeof b == 'string';
-// OK
+
typeof c != "string";
-// OK
+
"number" !== typeof 23;
-// OK
+
'object' == typeof null;
-// OK
+
typeof es6 === 'symbol';
-switch (typeof a) {
-// OK
+switch (typeof a) { // $ Alert
+
case 'undefined':
-// NOT OK
case 'null':
}
-// OK
+
switch (msg) {
case 'null':
case typeof a:
}
-// NOT OK
-(typeof a) === 'array';
+(typeof a) === 'array'; // $ Alert
// JScript extensions
typeof a === 'unknown' || typeof a === 'date';
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/ConditionalComments/ConditionalComments.qlref b/javascript/ql/test/query-tests/LanguageFeatures/ConditionalComments/ConditionalComments.qlref
index 8c331480b29c..908167804bcb 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/ConditionalComments/ConditionalComments.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/ConditionalComments/ConditionalComments.qlref
@@ -1 +1 @@
-LanguageFeatures/ConditionalComments.ql
+query: LanguageFeatures/ConditionalComments.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/DebuggerStatement/DebuggerStatement.qlref b/javascript/ql/test/query-tests/LanguageFeatures/DebuggerStatement/DebuggerStatement.qlref
index 6ec39aa879d7..ba16fbb07ece 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/DebuggerStatement/DebuggerStatement.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/DebuggerStatement/DebuggerStatement.qlref
@@ -1 +1,2 @@
-LanguageFeatures/DebuggerStatement.ql
+query: LanguageFeatures/DebuggerStatement.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/DebuggerStatement/debuggerStatement.js b/javascript/ql/test/query-tests/LanguageFeatures/DebuggerStatement/debuggerStatement.js
index b456e6b2b1d4..7c4a7fb098ef 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/DebuggerStatement/debuggerStatement.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/DebuggerStatement/debuggerStatement.js
@@ -1,3 +1,3 @@
function sayHello() {
- debugger;
+ debugger; // $ Alert
}
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/DeleteVar/DeleteVar.qlref b/javascript/ql/test/query-tests/LanguageFeatures/DeleteVar/DeleteVar.qlref
index 0da47afc6a0e..70d65313b52a 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/DeleteVar/DeleteVar.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/DeleteVar/DeleteVar.qlref
@@ -1 +1,2 @@
-LanguageFeatures/DeleteVar.ql
\ No newline at end of file
+query: LanguageFeatures/DeleteVar.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/DeleteVar/tst.js b/javascript/ql/test/query-tests/LanguageFeatures/DeleteVar/tst.js
index 1641372a53cc..8a6a7613d7a7 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/DeleteVar/tst.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/DeleteVar/tst.js
@@ -1,8 +1,8 @@
delete this.Object;
-delete String;
+delete String; // $ Alert
function f(o, x) {
delete o.p;
delete o[x];
- delete x;
+ delete x; // $ Alert
delete (o.p);
}
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/EmptyArrayInit/EmptyArrayInit.qlref b/javascript/ql/test/query-tests/LanguageFeatures/EmptyArrayInit/EmptyArrayInit.qlref
index f4decec514b3..142d91688dae 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/EmptyArrayInit/EmptyArrayInit.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/EmptyArrayInit/EmptyArrayInit.qlref
@@ -1 +1,2 @@
-LanguageFeatures/EmptyArrayInit.ql
\ No newline at end of file
+query: LanguageFeatures/EmptyArrayInit.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/EmptyArrayInit/tst.js b/javascript/ql/test/query-tests/LanguageFeatures/EmptyArrayInit/tst.js
index 69daffb8a0b0..cf64a97a4d10 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/EmptyArrayInit/tst.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/EmptyArrayInit/tst.js
@@ -1,7 +1,7 @@
-var a = [], // OK
- b = [1], // OK
- c = [1, 2], // OK
- d = [1, , 2], // NOT OK
- e = [1,], // OK
- f = [1, 2, ,], // NOT OK
- g = [,1]; // NOT OK
+var a = [],
+ b = [1],
+ c = [1, 2],
+ d = [1, , 2], // $ Alert
+ e = [1,],
+ f = [1, 2, ,], // $ Alert
+ g = [,1]; // $ Alert
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/Eval/Eval.qlref b/javascript/ql/test/query-tests/LanguageFeatures/Eval/Eval.qlref
index 65753c6e2076..f6cdc87d5359 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/Eval/Eval.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/Eval/Eval.qlref
@@ -1 +1,2 @@
-LanguageFeatures/Eval.ql
+query: LanguageFeatures/Eval.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/Eval/eval.js b/javascript/ql/test/query-tests/LanguageFeatures/Eval/eval.js
index 54ab88cd23e3..7845f9f07460 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/Eval/eval.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/Eval/eval.js
@@ -1,4 +1,4 @@
function sayHello() {
- eval("2+2");
+ eval("2+2"); // $ Alert
anotherFunction("2+2");
}
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/ExpressionClosures.expected b/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/ExpressionClosures.expected
index f3c95f56d3d2..01e87bf5c177 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/ExpressionClosures.expected
+++ b/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/ExpressionClosures.expected
@@ -3,4 +3,4 @@
| letExpr.js:3:13:3:38 | let (x ... ) x + y | Use let declarations instead of let expressions. |
| letStmt.js:3:1:5:1 | let (x ... + y);\\n} | Use let declarations instead of let statements. |
| postfixComprehension.js:2:15:2:38 | [i*i fo ... mbers)] | Use prefix comprehensions instead of postfix comprehensions. |
-| tst.js:2:15:2:31 | function(x) x * x | Use arrow expressions instead of expression closures. |
+| tst.js:1:15:1:31 | function(x) x * x | Use arrow expressions instead of expression closures. |
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/ExpressionClosures.qlref b/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/ExpressionClosures.qlref
index 422b2aeab8ee..ab1619db7165 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/ExpressionClosures.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/ExpressionClosures.qlref
@@ -1 +1,2 @@
-LanguageFeatures/ExpressionClosures.ql
\ No newline at end of file
+query: LanguageFeatures/ExpressionClosures.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/foreach.js b/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/foreach.js
index 1df300534371..2f22bc5dce39 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/foreach.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/foreach.js
@@ -3,6 +3,6 @@ var obj = {prop1: 5, prop2: 13, prop3: 8};
for each (var item in obj) {
sum += item;
-}
+} // $ Alert
console.log(sum); // logs "26", which is 5+13+8
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/jscript.js b/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/jscript.js
index 0f6a81c8fb36..7b85bc8720f3 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/jscript.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/jscript.js
@@ -1,3 +1,3 @@
-function window::onload() {}
+function window::onload() {} // $ Alert
window.onload = function onload() {}
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/letExpr.js b/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/letExpr.js
index a5c7a09b6be5..7c4b6c4eb804 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/letExpr.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/letExpr.js
@@ -1,5 +1,5 @@
var x = 42, y = 19;
-console.log(let (x = 23, y = 19) x + y);
+console.log(let (x = 23, y = 19) x + y); // $ Alert
console.log(x - y);
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/letStmt.js b/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/letStmt.js
index 69beaac8a096..3b62e7f0d14c 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/letStmt.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/letStmt.js
@@ -2,6 +2,6 @@ var x = 42, y = 19;
let (x = 23, y = 19) {
console.log(x + y);
-}
+} // $ Alert
console.log(x - y);
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/postfixComprehension.js b/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/postfixComprehension.js
index 3cca1b5c615f..181c90cfa7fe 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/postfixComprehension.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/postfixComprehension.js
@@ -1,4 +1,4 @@
var numbers = [1, 2, 3, 4, 5];
-var squares = [i*i for (i of numbers)];
+var squares = [i*i for (i of numbers)]; // $ Alert
var specialKeyCodes = [for (keyCodeName of Object.keys(SPECIAL_CODES_MAP))
SPECIAL_CODES_MAP[keyCodeName]];
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/tst.js b/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/tst.js
index 202ea2a262a6..610590712eeb 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/tst.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/ExpressionClosures/tst.js
@@ -1,8 +1,7 @@
-// NOT OK
-[1, 2, 3].map(function(x) x * x);
+[1, 2, 3].map(function(x) x * x); // $ Alert
+
-// OK
[1, 2, 3].map(function(x) { return x * x; });
-// OK
+
[1, 2, 3].map((x) => x * x);
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/ForInComprehensionBlocks/ForInComprehensionBlocks.qlref b/javascript/ql/test/query-tests/LanguageFeatures/ForInComprehensionBlocks/ForInComprehensionBlocks.qlref
index 57bc034bdf70..d5b6deb7355b 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/ForInComprehensionBlocks/ForInComprehensionBlocks.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/ForInComprehensionBlocks/ForInComprehensionBlocks.qlref
@@ -1 +1,2 @@
-LanguageFeatures/ForInComprehensionBlocks.ql
\ No newline at end of file
+query: LanguageFeatures/ForInComprehensionBlocks.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/ForInComprehensionBlocks/tst.js b/javascript/ql/test/query-tests/LanguageFeatures/ForInComprehensionBlocks/tst.js
index 08542e2be521..3ada68d3cf02 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/ForInComprehensionBlocks/tst.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/ForInComprehensionBlocks/tst.js
@@ -1,2 +1,2 @@
var a = [23,,42];
-var desc = [for(i in a) i + " = a[" + i + "]"];
+var desc = [for(i in a) i + " = a[" + i + "]"]; // $ Alert
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/IllegalInvocation/IllegalInvocation.qlref b/javascript/ql/test/query-tests/LanguageFeatures/IllegalInvocation/IllegalInvocation.qlref
index 1297139b9f9a..d1cf5afbb2ac 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/IllegalInvocation/IllegalInvocation.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/IllegalInvocation/IllegalInvocation.qlref
@@ -1 +1,2 @@
-LanguageFeatures/IllegalInvocation.ql
\ No newline at end of file
+query: LanguageFeatures/IllegalInvocation.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/IllegalInvocation/tst.js b/javascript/ql/test/query-tests/LanguageFeatures/IllegalInvocation/tst.js
index 3ed85a709341..48af86687794 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/IllegalInvocation/tst.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/IllegalInvocation/tst.js
@@ -4,24 +4,24 @@ class C {
class D extends C {
constructor() {
- super(); // OK
+ super();
}
}
-let c = new C(); // OK
-C(); // NOT OK
-new (x=>x); // NOT OK
-c.m(); // OK
-new c.m(); // NOT OK - but not flagged
+let c = new C();
+C(); // $ Alert
+new (x=>x); // $ Alert
+c.m();
+new c.m(); // $ MISSING: Alert
var o = {
f: function() {},
g() {}
};
-o.f(); // OK
-new o.f(); // OK
-o.g(); // OK
-new o.g(); // NOT OK - but not flagged
+o.f();
+new o.f();
+o.g();
+new o.g(); // $ MISSING: Alert
function f(b) {
var g;
@@ -31,31 +31,31 @@ function f(b) {
g = (() => {});
console.log();
if (!b)
- g(); // OK
+ g();
else
- new g(); // OK
+ new g();
}
function* g() {}
async function h() {}
-new g() // NOT OK
-new h() // NOT OK
+new g() // $ Alert
+new h() // $ Alert
-C.call(); // NOT OK
-C.apply(); // NOT OK
+C.call(); // $ Alert
+C.apply(); // $ Alert
class E {
static call() {}
static apply() {}
}
-E.call(); // OK
-E.apply(); // OK
+E.call();
+E.apply();
function invoke(fn) {
if (typeof fn === "function" && fn.hasOwnProperty("foo")) {
- fn(); // OK
+ fn();
}
}
invoke(C);
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/InconsistentNew.expected b/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/InconsistentNew.expected
index 0c03a59fd223..e2aa2ed56f3e 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/InconsistentNew.expected
+++ b/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/InconsistentNew.expected
@@ -1,2 +1,2 @@
-| m.js:1:8:1:22 | functio ... = x;\\n} | Function A is sometimes invoked as a constructor (for example $@), and sometimes as a normal function (for example $@). | c1.js:2:1:2:9 | new A(42) | here | c2.js:2:1:2:5 | A(23) | here |
-| tst.js:1:1:1:22 | functio ... = y;\\n} | Function Point is sometimes invoked as a constructor (for example $@), and sometimes as a normal function (for example $@). | tst.js:6:1:6:17 | new Point(23, 42) | here | tst.js:7:1:7:13 | Point(56, 72) | here |
+| m.js:1:8:1:33 | functio ... = x;\\n} | Function A is sometimes invoked as a constructor (for example $@), and sometimes as a normal function (for example $@). | c1.js:2:1:2:9 | new A(42) | here | c2.js:2:1:2:5 | A(23) | here |
+| tst.js:1:1:1:33 | functio ... = y;\\n} | Function Point is sometimes invoked as a constructor (for example $@), and sometimes as a normal function (for example $@). | tst.js:6:1:6:17 | new Point(23, 42) | here | tst.js:7:1:7:13 | Point(56, 72) | here |
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/InconsistentNew.qlref b/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/InconsistentNew.qlref
index 8c5695ffb85c..a03be885e21c 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/InconsistentNew.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/InconsistentNew.qlref
@@ -1 +1,2 @@
-LanguageFeatures/InconsistentNew.ql
\ No newline at end of file
+query: LanguageFeatures/InconsistentNew.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/a1.js b/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/a1.js
index 1585d8add718..3ecf658e45c9 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/a1.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/a1.js
@@ -1,3 +1,3 @@
function A() {}
-new A(); // OK
-String(""); // OK
\ No newline at end of file
+new A();
+String("");
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/a2.js b/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/a2.js
index 407b91aec013..1c9f2e07a49a 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/a2.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/a2.js
@@ -1,6 +1,6 @@
function A() {}
-A(); // OK
+A();
function MyString() {}
String = MyString;
-new String(); // OK
\ No newline at end of file
+new String();
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/arraycalls.js b/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/arraycalls.js
index 6aaeaa7a9f18..a3477727286b 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/arraycalls.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/arraycalls.js
@@ -1,2 +1,2 @@
-Array(45); // OK
-new Array(45); // OK
+Array(45);
+new Array(45);
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/m.js b/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/m.js
index 416caeb40635..1bc9fbf5f537 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/m.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/m.js
@@ -1,3 +1,3 @@
-export function A(x) {
+export function A(x) { // $ Alert
this.x = x;
};
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/tst.js b/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/tst.js
index 56af21411b67..fb22e98ade67 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/tst.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/InconsistentNew/tst.js
@@ -1,4 +1,4 @@
-function Point(x, y) {
+function Point(x, y) { // $ Alert
this.x = x;
this.y = y;
}
@@ -48,13 +48,13 @@ function RobustPoint4(x, y) {
new RobustPoint4(23, 42);
RobustPoint4(56, 72);
-// OK: Error is an external function
+// OK - Error is an external function
new Error();
Error();
class C {}
new C();
-C(); // NOT OK, but flagged by IllegalInvocation
+C(); // OK - flagged by IllegalInvocation
(function() {
function A(x) {
@@ -64,5 +64,5 @@ C(); // NOT OK, but flagged by IllegalInvocation
A.call({}, 23);
})();
-new Point(42, 23); // NOT OK, but not flagged since line 6 above was already flagged
-Point(56, 72); // NOT OK, but not flagged since line 7 above was already flagged
+new Point(42, 23); // OK - not flagged since line 6 above was already flagged
+Point(56, 72); // OK - not flagged since line 7 above was already flagged
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/InvalidPrototype/InvalidPrototype.qlref b/javascript/ql/test/query-tests/LanguageFeatures/InvalidPrototype/InvalidPrototype.qlref
index 04e81233ed77..307244114cbc 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/InvalidPrototype/InvalidPrototype.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/InvalidPrototype/InvalidPrototype.qlref
@@ -1 +1,2 @@
-LanguageFeatures/InvalidPrototype.ql
\ No newline at end of file
+query: LanguageFeatures/InvalidPrototype.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/InvalidPrototype/tst.js b/javascript/ql/test/query-tests/LanguageFeatures/InvalidPrototype/tst.js
index 1015db92cff4..5c12a3b7d853 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/InvalidPrototype/tst.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/InvalidPrototype/tst.js
@@ -1,11 +1,11 @@
-var o1 = { __proto__: null }; // OK
-Object.setPrototypeOf(o1, Function.prototype); // OK
-Object.create(class{}); // OK
-Function.prototype.isPrototypeOf(o1); // OK
-o1.__proto__ = new Date(); // OK
+var o1 = { __proto__: null };
+Object.setPrototypeOf(o1, Function.prototype);
+Object.create(class{});
+Function.prototype.isPrototypeOf(o1);
+o1.__proto__ = new Date();
-var o2 = { __proto__: undefined }; // NOT OK
-Object.setPrototypeOf(o2, 42); // NOT OK
-Object.create(true); // NOT OK
-"function".isPrototypeOf(o2); // NOT OK
+var o2 = { __proto__: undefined }; // $ Alert
+Object.setPrototypeOf(o2, 42); // $ Alert
+Object.create(true); // $ Alert
+"function".isPrototypeOf(o2); // $ Alert
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/JumpFromFinally/JumpFromFinally.qlref b/javascript/ql/test/query-tests/LanguageFeatures/JumpFromFinally/JumpFromFinally.qlref
index f76a131eff46..6404cd83590e 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/JumpFromFinally/JumpFromFinally.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/JumpFromFinally/JumpFromFinally.qlref
@@ -1 +1,2 @@
-LanguageFeatures/JumpFromFinally.ql
\ No newline at end of file
+query: LanguageFeatures/JumpFromFinally.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/JumpFromFinally/tst.js b/javascript/ql/test/query-tests/LanguageFeatures/JumpFromFinally/tst.js
index 0cf40521ad93..d875f1c1d03e 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/JumpFromFinally/tst.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/JumpFromFinally/tst.js
@@ -4,7 +4,7 @@ function foo(resource) {
throw new Error();
} finally {
resource.close();
- return true;
+ return true; // $ Alert
}
}
@@ -25,7 +25,7 @@ function baz(resource) {
throw new Error();
} finally {
resource.close();
- break;
+ break; // $ Alert
}
}
}
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/LengthComparisonOffByOne/LengthComparisonOffByOne.expected b/javascript/ql/test/query-tests/LanguageFeatures/LengthComparisonOffByOne/LengthComparisonOffByOne.expected
index 2af10be24c0d..c9b2667e9e74 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/LengthComparisonOffByOne/LengthComparisonOffByOne.expected
+++ b/javascript/ql/test/query-tests/LanguageFeatures/LengthComparisonOffByOne/LengthComparisonOffByOne.expected
@@ -1,7 +1,7 @@
-| tst.js:2:17:2:32 | i <= args.length | Off-by-one index comparison against length may lead to out-of-bounds $@. | tst.js:3:15:3:21 | args[i] | read |
-| tst.js:7:17:7:32 | args.length >= i | Off-by-one index comparison against length may lead to out-of-bounds $@. | tst.js:8:15:8:21 | args[i] | read |
-| tst.js:18:5:18:20 | j <= args.length | Off-by-one index comparison against length may lead to out-of-bounds $@. | tst.js:19:15:19:21 | args[j] | read |
-| tst.js:23:5:23:20 | args.length >= j | Off-by-one index comparison against length may lead to out-of-bounds $@. | tst.js:24:15:24:21 | args[j] | read |
-| tst.js:34:19:34:31 | i <= a.length | Off-by-one index comparison against length may lead to out-of-bounds $@. | tst.js:35:9:35:12 | a[i] | read |
-| tst.js:51:9:51:21 | i <= a.length | Off-by-one index comparison against length may lead to out-of-bounds $@. | tst.js:51:43:51:46 | a[i] | read |
-| tst.js:51:26:51:38 | i <= b.length | Off-by-one index comparison against length may lead to out-of-bounds $@. | tst.js:51:52:51:55 | b[i] | read |
+| tst.js:1:17:1:32 | i <= args.length | Off-by-one index comparison against length may lead to out-of-bounds $@. | tst.js:2:15:2:21 | args[i] | read |
+| tst.js:5:17:5:32 | args.length >= i | Off-by-one index comparison against length may lead to out-of-bounds $@. | tst.js:6:15:6:21 | args[i] | read |
+| tst.js:15:5:15:20 | j <= args.length | Off-by-one index comparison against length may lead to out-of-bounds $@. | tst.js:16:15:16:21 | args[j] | read |
+| tst.js:19:5:19:20 | args.length >= j | Off-by-one index comparison against length may lead to out-of-bounds $@. | tst.js:20:15:20:21 | args[j] | read |
+| tst.js:29:19:29:31 | i <= a.length | Off-by-one index comparison against length may lead to out-of-bounds $@. | tst.js:30:9:30:12 | a[i] | read |
+| tst.js:46:9:46:21 | i <= a.length | Off-by-one index comparison against length may lead to out-of-bounds $@. | tst.js:46:43:46:46 | a[i] | read |
+| tst.js:46:26:46:38 | i <= b.length | Off-by-one index comparison against length may lead to out-of-bounds $@. | tst.js:46:52:46:55 | b[i] | read |
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/LengthComparisonOffByOne/LengthComparisonOffByOne.qlref b/javascript/ql/test/query-tests/LanguageFeatures/LengthComparisonOffByOne/LengthComparisonOffByOne.qlref
index 4b12bd2f70ba..2514b6d76698 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/LengthComparisonOffByOne/LengthComparisonOffByOne.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/LengthComparisonOffByOne/LengthComparisonOffByOne.qlref
@@ -1 +1,2 @@
-LanguageFeatures/LengthComparisonOffByOne.ql
\ No newline at end of file
+query: LanguageFeatures/LengthComparisonOffByOne.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/LengthComparisonOffByOne/tst.js b/javascript/ql/test/query-tests/LanguageFeatures/LengthComparisonOffByOne/tst.js
index c819b10ad56a..6b214c9b0423 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/LengthComparisonOffByOne/tst.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/LengthComparisonOffByOne/tst.js
@@ -1,43 +1,38 @@
-// BAD: Loop upper bound is off-by-one
-for (var i = 0; i <= args.length; i++) {
+for (var i = 0; i <= args.length; i++) { // $ Alert - Loop upper bound is off-by-one
console.log(args[i]);
}
-// BAD: Loop upper bound is off-by-one
-for (var i = 0; args.length >= i; i++) {
+for (var i = 0; args.length >= i; i++) { // $ Alert - Loop upper bound is off-by-one
console.log(args[i]);
}
-// GOOD: Loop upper bound is correct
+// OK - Loop upper bound is correct
for (var i = 0; i < args.length; i++) {
console.log(args[i]);
}
var j = 0;
-// BAD: Off-by-one on index validity check
-if (j <= args.length) {
+if (j <= args.length) { // $ Alert - Off-by-one on index validity check
console.log(args[j]);
}
-// BAD: Off-by-one on index validity check
-if (args.length >= j) {
+if (args.length >= j) { // $ Alert - Off-by-one on index validity check
console.log(args[j]);
}
-// GOOD: Correct terminating value
+// OK - Correct terminating value
if (args.length > j) {
console.log(args[j]);
}
-// BAD: incorrect upper bound
-function badContains(a, elt) {
- for (let i = 0; i <= a.length; ++i)
+function badContains(a, elt) { // incorrect upper bound
+ for (let i = 0; i <= a.length; ++i) // $ Alert
if (a[i] === elt)
return true;
return false;
}
-// GOOD: correct upper bound
+// OK - correct upper bound
function goodContains(a, elt) {
for (let i = 0; i < a.length; ++i)
if (a[i] === elt)
@@ -48,12 +43,12 @@ function goodContains(a, elt) {
// this is arguably OK, but we flag it
function same(a, b) {
for (var i=0; i < a.length || i < b.length ; ++i)
- if (i <= a.length && i <= b.length && a[i] !== b[i])
+ if (i <= a.length && i <= b.length && a[i] !== b[i]) // $ Alert
return false;
return true;
}
-// GOOD: incorrect upper bound, but extra check
+// OK - incorrect upper bound, but extra check
function badContains(a, elt) {
for (let i = 0; i <= a.length; ++i)
if (i !== a.length && a[i] === elt)
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/NonLinearPattern.expected b/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/NonLinearPattern.expected
index 2f61724a5661..31d9fc228113 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/NonLinearPattern.expected
+++ b/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/NonLinearPattern.expected
@@ -1,11 +1,11 @@
| NonLinearPatternTS.ts:1:34:1:39 | number | The pattern variable 'number' appears to be a type, but is a variable $@. | NonLinearPatternTS.ts:1:23:1:28 | number | previously bound |
-| ts-test.ts:3:13:3:13 | x | Repeated binding of pattern variable 'x' $@. | ts-test.ts:3:10:3:10 | x | previously bound |
-| ts-test.ts:8:16:8:16 | x | Repeated binding of pattern variable 'x' $@. | ts-test.ts:8:10:8:10 | x | previously bound |
-| ts-test.ts:11:10:11:10 | x | Repeated binding of pattern variable 'x' $@. | ts-test.ts:11:7:11:7 | x | previously bound |
-| ts-test.ts:21:8:21:13 | string | The pattern variable 'string' appears to be a type, but is a variable $@. | ts-test.ts:20:8:20:13 | string | previously bound |
-| ts-test.ts:32:16:32:16 | x | Repeated binding of pattern variable 'x' $@. | ts-test.ts:30:12:30:12 | x | previously bound |
-| ts-test.ts:34:20:34:20 | x | Repeated binding of pattern variable 'x' $@. | ts-test.ts:30:12:30:12 | x | previously bound |
-| ts-test.ts:40:27:40:32 | string | Repeated binding of pattern variable 'string' $@. | ts-test.ts:40:16:40:21 | string | previously bound |
-| tst.js:3:13:3:13 | x | Repeated binding of pattern variable 'x' $@. | tst.js:3:10:3:10 | x | previously bound |
-| tst.js:8:16:8:16 | x | Repeated binding of pattern variable 'x' $@. | tst.js:8:10:8:10 | x | previously bound |
-| tst.js:11:10:11:10 | x | Repeated binding of pattern variable 'x' $@. | tst.js:11:7:11:7 | x | previously bound |
+| ts-test.ts:2:13:2:13 | x | Repeated binding of pattern variable 'x' $@. | ts-test.ts:2:10:2:10 | x | previously bound |
+| ts-test.ts:6:16:6:16 | x | Repeated binding of pattern variable 'x' $@. | ts-test.ts:6:10:6:10 | x | previously bound |
+| ts-test.ts:8:10:8:10 | x | Repeated binding of pattern variable 'x' $@. | ts-test.ts:8:7:8:7 | x | previously bound |
+| ts-test.ts:18:8:18:13 | string | The pattern variable 'string' appears to be a type, but is a variable $@. | ts-test.ts:17:8:17:13 | string | previously bound |
+| ts-test.ts:29:16:29:16 | x | Repeated binding of pattern variable 'x' $@. | ts-test.ts:27:12:27:12 | x | previously bound |
+| ts-test.ts:31:20:31:20 | x | Repeated binding of pattern variable 'x' $@. | ts-test.ts:27:12:27:12 | x | previously bound |
+| ts-test.ts:37:27:37:32 | string | Repeated binding of pattern variable 'string' $@. | ts-test.ts:37:16:37:21 | string | previously bound |
+| tst.js:2:13:2:13 | x | Repeated binding of pattern variable 'x' $@. | tst.js:2:10:2:10 | x | previously bound |
+| tst.js:6:16:6:16 | x | Repeated binding of pattern variable 'x' $@. | tst.js:6:10:6:10 | x | previously bound |
+| tst.js:8:10:8:10 | x | Repeated binding of pattern variable 'x' $@. | tst.js:8:7:8:7 | x | previously bound |
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/NonLinearPattern.qlref b/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/NonLinearPattern.qlref
index 322a10d00085..5684a790f6cc 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/NonLinearPattern.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/NonLinearPattern.qlref
@@ -1 +1,2 @@
-LanguageFeatures/NonLinearPattern.ql
\ No newline at end of file
+query: LanguageFeatures/NonLinearPattern.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/NonLinearPatternTS.ts b/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/NonLinearPatternTS.ts
index d19e8bb327fc..2ff108ddb8a1 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/NonLinearPatternTS.ts
+++ b/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/NonLinearPatternTS.ts
@@ -1,3 +1,3 @@
-function distance({x: number, y: number}) {
+function distance({x: number, y: number}) { // $ Alert
return Math.sqrt(x*x + y*y);
}
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/ts-test.ts b/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/ts-test.ts
index 1198d2c5ff74..120fa7098ee5 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/ts-test.ts
+++ b/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/ts-test.ts
@@ -1,41 +1,38 @@
function distanceFromOrigin(point) {
- // NOT OK
- var [x, x] = point;
+ var [x, x] = point; // $ Alert
return Math.sqrt(x*x + y*y);
}
-// NOT OK
-var { x: x, y: x } = o;
+var { x: x, y: x } = o; // $ Alert
+
+var { x, x } = o; // $ Alert
-// NOT OK
-var { x, x } = o;
-// OK
var { x: x, x: y } = o;
-// OK
+
var { p = x, q = x } = o;
function f({
x: string,
- y: string // NOT OK
+ y: string // $ Alert
}) {
}
-function g({x, y}: {x: string, y: string}) { // OK
+function g({x, y}: {x: string, y: string}) {
}
function blah(arg) {
var {
x: x,
y: {
- x: x, // NOT OK
+ x: x, // $ Alert
y: {
- x: x // NOT OK
+ x: x // $ Alert
}
}
} = arg;
}
-function h({x: string, y: string}: any) { // NOT OK
+function h({x: string, y: string}: any) { // $ Alert
}
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/tst.js b/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/tst.js
index 0e6b79f4675f..017499000358 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/tst.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/NonLinearPattern/tst.js
@@ -1,17 +1,14 @@
function distanceFromOrigin(point) {
- // NOT OK
- var [x, x] = point;
+ var [x, x] = point; // $ Alert
return Math.sqrt(x*x + y*y);
}
-// NOT OK
-var { x: x, y: x } = o;
+var { x: x, y: x } = o; // $ Alert
+
+var { x, x } = o; // $ Alert
-// NOT OK
-var { x, x } = o;
-// OK
var { x: x, x: y } = o;
-// OK
+
var { p = x, q = x } = o;
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/PropertyWriteOnPrimitive/PropertyWriteOnPrimitive.expected b/javascript/ql/test/query-tests/LanguageFeatures/PropertyWriteOnPrimitive/PropertyWriteOnPrimitive.expected
index 9dcd49a99d3f..75d8c23b51f6 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/PropertyWriteOnPrimitive/PropertyWriteOnPrimitive.expected
+++ b/javascript/ql/test/query-tests/LanguageFeatures/PropertyWriteOnPrimitive/PropertyWriteOnPrimitive.expected
@@ -1,3 +1,3 @@
-| tst.js:2:1:2:3 | (0) | Assignment to property foo of a primitive value with type number. |
-| tst.js:11:5:11:5 | s | Assignment to a property of a primitive value with type string. |
-| tst.js:17:3:17:3 | x | Assignment to property y of a primitive value with type number or string. |
+| tst.js:1:1:1:3 | (0) | Assignment to property foo of a primitive value with type number. |
+| tst.js:8:5:8:5 | s | Assignment to a property of a primitive value with type string. |
+| tst.js:13:3:13:3 | x | Assignment to property y of a primitive value with type number or string. |
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/PropertyWriteOnPrimitive/PropertyWriteOnPrimitive.qlref b/javascript/ql/test/query-tests/LanguageFeatures/PropertyWriteOnPrimitive/PropertyWriteOnPrimitive.qlref
index f57cf67c800c..6dccd34408b6 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/PropertyWriteOnPrimitive/PropertyWriteOnPrimitive.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/PropertyWriteOnPrimitive/PropertyWriteOnPrimitive.qlref
@@ -1 +1,2 @@
-LanguageFeatures/PropertyWriteOnPrimitive.ql
\ No newline at end of file
+query: LanguageFeatures/PropertyWriteOnPrimitive.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/PropertyWriteOnPrimitive/tst.js b/javascript/ql/test/query-tests/LanguageFeatures/PropertyWriteOnPrimitive/tst.js
index 5d83bad877dc..a74ffbc860a2 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/PropertyWriteOnPrimitive/tst.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/PropertyWriteOnPrimitive/tst.js
@@ -1,24 +1,20 @@
-// NOT OK
-(0).foo = 42;
+(0).foo = 42; // $ Alert
-// NOT OK, but already flagged by SuspiciousPropAccess.ql
-null.bar = 23; undefined.baz = 42;
+null.bar = 23; undefined.baz = 42; // OK - already flagged by SuspiciousPropAccess.ql
function f() {
var s = "";
for (var i=0;i<10;++i)
- // NOT OK
- s[i] = " ";
+ s[i] = " "; // $ Alert
}
function g(b) {
var x = b ? "" : 42, z;
- // NOT OK
- x.y = true;
- // OK: we don't know the type of `b`
+ x.y = true; // $ Alert
+ // OK - we don't know the type of `b`
b.y = true;
return;
- // OK: no types inferred for `z`, since this is dead code
+ // OK - no types inferred for `z`, since this is dead code
z.y = true;
}
@@ -26,4 +22,4 @@ function h() {
let tmp;
let obj = (tmp ||= {});
obj.p = 42;
-}
\ No newline at end of file
+}
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SemicolonInsertion/SemicolonInsertion.qlref b/javascript/ql/test/query-tests/LanguageFeatures/SemicolonInsertion/SemicolonInsertion.qlref
index 2419fbd90b9b..b84aceb435ad 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SemicolonInsertion/SemicolonInsertion.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SemicolonInsertion/SemicolonInsertion.qlref
@@ -1 +1,2 @@
-LanguageFeatures/SemicolonInsertion.ql
+query: LanguageFeatures/SemicolonInsertion.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SemicolonInsertion/export.js b/javascript/ql/test/query-tests/LanguageFeatures/SemicolonInsertion/export.js
index 7e06517fe174..4c95a6eb67dc 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SemicolonInsertion/export.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SemicolonInsertion/export.js
@@ -2,7 +2,7 @@ export default function f() {
return 23;
}
-export var x = 42
+export var x = 42 // $ Alert
//pad with enough explicit semicolons to satisfy 90% threshold
foo();
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SemicolonInsertion/jscript.js b/javascript/ql/test/query-tests/LanguageFeatures/SemicolonInsertion/jscript.js
index 5e9b07cf6757..6f125751c3a2 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SemicolonInsertion/jscript.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SemicolonInsertion/jscript.js
@@ -1,6 +1,6 @@
function window::onload() {}
-window.onload = function onload() {}
+window.onload = function onload() {} // $ Alert
// pad with enough explicit semicolons to satisfy 90% threshold
foo();
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SemicolonInsertion/tst.js b/javascript/ql/test/query-tests/LanguageFeatures/SemicolonInsertion/tst.js
index 9b1d6f668923..3c296665f301 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SemicolonInsertion/tst.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SemicolonInsertion/tst.js
@@ -1,22 +1,22 @@
function tst() {
- var a = { // NOT OK
+ var a = {
'i': 1,
'j': 2
- }
+ } // $ Alert
- return 1 // NOT OK
+ return 1 // $ Alert
- if (condition) { // OK
+ if (condition) {
}
- for (i = 0; i < 10; i++) { // OK
+ for (i = 0; i < 10; i++) {
}
- label: while (condition) { // OK
- break label; // OK
+ label: while (condition) {
+ break label;
}
- return 1; // OK
+ return 1;
//pad with enough explicit semicolons to satisfy 90% threshold
foo();
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SetterIgnoresParameter/SetterIgnoresParameter.expected b/javascript/ql/test/query-tests/LanguageFeatures/SetterIgnoresParameter/SetterIgnoresParameter.expected
index bf01936dd730..e49869816edf 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SetterIgnoresParameter/SetterIgnoresParameter.expected
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SetterIgnoresParameter/SetterIgnoresParameter.expected
@@ -1,2 +1,2 @@
-| tst.js:15:3:15:12 | set x(v ... OK\\n\\t\\t} | This setter function does not use its parameter $@. | tst.js:15:9:15:9 | v | v |
-| tst.js:40:3:40:25 | set y(_ ... _x\|0; } | This setter function does not use its parameter $@. | tst.js:40:9:40:10 | _y | _y |
+| tst.js:15:3:15:23 | set x(v ... ert\\n\\t\\t} | This setter function does not use its parameter $@. | tst.js:15:9:15:9 | v | v |
+| tst.js:38:3:38:25 | set y(_ ... _x\|0; } | This setter function does not use its parameter $@. | tst.js:38:9:38:10 | _y | _y |
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SetterIgnoresParameter/SetterIgnoresParameter.qlref b/javascript/ql/test/query-tests/LanguageFeatures/SetterIgnoresParameter/SetterIgnoresParameter.qlref
index c5e101163a52..f090c96c40ce 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SetterIgnoresParameter/SetterIgnoresParameter.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SetterIgnoresParameter/SetterIgnoresParameter.qlref
@@ -1 +1,2 @@
-LanguageFeatures/SetterIgnoresParameter.ql
\ No newline at end of file
+query: LanguageFeatures/SetterIgnoresParameter.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SetterIgnoresParameter/tst.js b/javascript/ql/test/query-tests/LanguageFeatures/SetterIgnoresParameter/tst.js
index 22439c1e4f91..58682204ca5f 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SetterIgnoresParameter/tst.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SetterIgnoresParameter/tst.js
@@ -5,27 +5,26 @@ function A() {
return _a;
},
set a(v) {
- // OK
+
_a = v|0
},
get x() {
return _x;
},
- set x(v) {
- // NOT OK
+ set x(v) { // $ Alert
},
get y() {
return 56;
},
set y(v) {
- // OK
+
throw new Error("Cannot mutate y.");
},
set z(v) {
- // OK
+
_z = arguments[0] | 0;
}
};
@@ -36,7 +35,6 @@ function Point(x, y) {
get x() { return x; },
set x(_x) { x = _x|0; },
get y() { return y; },
- // NOT OK
- set y(_y) { x = _x|0; }
+ set y(_y) { x = _x|0; } // $ Alert
};
}
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SetterReturn/SetterReturn.expected b/javascript/ql/test/query-tests/LanguageFeatures/SetterReturn/SetterReturn.expected
index a5e92e24b4bd..2b911b330b6c 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SetterReturn/SetterReturn.expected
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SetterReturn/SetterReturn.expected
@@ -1 +1 @@
-| tst.js:15:3:15:16 | return "nope"; | Useless return statement in setter function. |
+| tst.js:14:3:14:16 | return "nope"; | Useless return statement in setter function. |
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SetterReturn/SetterReturn.qlref b/javascript/ql/test/query-tests/LanguageFeatures/SetterReturn/SetterReturn.qlref
index 93a02072150c..0c6e38131cc4 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SetterReturn/SetterReturn.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SetterReturn/SetterReturn.qlref
@@ -1 +1,2 @@
-LanguageFeatures/SetterReturn.ql
\ No newline at end of file
+query: LanguageFeatures/SetterReturn.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SetterReturn/tst.js b/javascript/ql/test/query-tests/LanguageFeatures/SetterReturn/tst.js
index 4211400e6c48..5c7ea043cbe2 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SetterReturn/tst.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SetterReturn/tst.js
@@ -1,17 +1,16 @@
var o = {
_secret_x: 42,
get x() {
- // OK
+
return 42;
},
set x(v) {
if (v !== 42)
- // OK
+
return;
_secret_x = v;
},
set y(w) {
- // NOT OK
- return "nope";
+ return "nope"; // $ Alert
}
}
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/SpuriousArguments.expected b/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/SpuriousArguments.expected
index 92b3fc978773..b88dd7d68e80 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/SpuriousArguments.expected
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/SpuriousArguments.expected
@@ -8,17 +8,17 @@
| reflection.js:7:15:7:18 | 1 | Superfluous arguments passed to $@. | reflection.js:1:1:1:23 | functio ... eturn;} | function f0 |
| reflection.js:12:18:12:18 | 2 | Superfluous argument passed to $@. | reflection.js:2:1:2:24 | functio ... eturn;} | function f1 |
| thisparameter.ts:4:11:4:12 | 45 | Superfluous argument passed to $@. | thisparameter.ts:1:1:1:45 | functio ... eturn;} | function foo |
-| tst.js:11:3:11:5 | g() | Superfluous argument passed to $@. | tst.js:1:1:4:1 | functio ... x+19;\\n} | function f |
-| tst.js:33:15:33:18 | 2 | Superfluous arguments passed to $@. | externs.js:34:1:34:27 | functio ... str) {} | function String |
-| tst.js:37:4:37:5 | 42 | Superfluous argument passed to $@. | tst.js:38:4:38:23 | function() {return;} | anonymous function |
-| tst.js:46:19:46:20 | 10 | Superfluous argument passed to $@. | externs.js:36:1:36:27 | functio ... num) {} | function parseFloat |
-| tst.js:70:11:70:12 | 42 | Superfluous argument passed to $@. | tst.js:49:2:51:2 | functio ... urn;\\n\\t} | function nonEmpty |
-| tst.js:75:13:75:14 | 42 | Superfluous argument passed to $@. | tst.js:63:19:63:33 | () => undefined | function emptyArrow |
-| tst.js:76:31:76:32 | 42 | Superfluous argument passed to $@. | tst.js:64:33:64:32 | () {} | default constructor of class ImplicitEmptyConstructor |
-| tst.js:77:31:77:32 | 42 | Superfluous argument passed to $@. | tst.js:67:14:68:3 | (){\\n\\t\\t} | constructor of class ExplicitEmptyConstructor |
-| tst.js:78:20:78:21 | 10 | Superfluous argument passed to $@. | externs.js:36:1:36:27 | functio ... num) {} | function parseFloat |
-| tst.js:114:20:114:21 | 42 | Superfluous argument passed to $@. | tst.js:82:2:86:2 | functio ... \\n\\t\\t}\\n\\t} | function notAPlainThrower1 |
-| tst.js:115:20:115:21 | 42 | Superfluous argument passed to $@. | tst.js:87:2:90:2 | functio ... .");\\n\\t} | function notAPlainThrower2 |
-| tst.js:116:20:116:21 | 42 | Superfluous argument passed to $@. | tst.js:91:2:94:2 | functio ... .");\\n\\t} | function notAPlainThrower3 |
-| tst.js:120:23:120:24 | 87 | Superfluous argument passed to $@. | tst.js:102:2:104:2 | functio ... (p);\\n\\t} | function throwerWithParam |
-| tst.js:121:18:121:19 | 42 | Superfluous argument passed to $@. | tst.js:105:2:113:2 | functio ... )();\\n\\t} | function throwerIndirect |
+| tst.js:10:3:10:5 | g() | Superfluous argument passed to $@. | tst.js:1:1:4:1 | functio ... x+19;\\n} | function f |
+| tst.js:31:15:31:18 | 2 | Superfluous arguments passed to $@. | externs.js:34:1:34:27 | functio ... str) {} | function String |
+| tst.js:34:4:34:5 | 42 | Superfluous argument passed to $@. | tst.js:35:4:35:23 | function() {return;} | anonymous function |
+| tst.js:43:19:43:20 | 10 | Superfluous argument passed to $@. | externs.js:36:1:36:27 | functio ... num) {} | function parseFloat |
+| tst.js:67:11:67:12 | 42 | Superfluous argument passed to $@. | tst.js:46:2:48:2 | functio ... urn;\\n\\t} | function nonEmpty |
+| tst.js:72:13:72:14 | 42 | Superfluous argument passed to $@. | tst.js:60:19:60:33 | () => undefined | function emptyArrow |
+| tst.js:73:31:73:32 | 42 | Superfluous argument passed to $@. | tst.js:61:33:61:32 | () {} | default constructor of class ImplicitEmptyConstructor |
+| tst.js:74:31:74:32 | 42 | Superfluous argument passed to $@. | tst.js:64:14:65:3 | (){\\n\\t\\t} | constructor of class ExplicitEmptyConstructor |
+| tst.js:75:20:75:21 | 10 | Superfluous argument passed to $@. | externs.js:36:1:36:27 | functio ... num) {} | function parseFloat |
+| tst.js:111:20:111:21 | 42 | Superfluous argument passed to $@. | tst.js:79:2:83:2 | functio ... \\n\\t\\t}\\n\\t} | function notAPlainThrower1 |
+| tst.js:112:20:112:21 | 42 | Superfluous argument passed to $@. | tst.js:84:2:87:2 | functio ... .");\\n\\t} | function notAPlainThrower2 |
+| tst.js:113:20:113:21 | 42 | Superfluous argument passed to $@. | tst.js:88:2:91:2 | functio ... .");\\n\\t} | function notAPlainThrower3 |
+| tst.js:117:23:117:24 | 87 | Superfluous argument passed to $@. | tst.js:99:2:101:2 | functio ... (p);\\n\\t} | function throwerWithParam |
+| tst.js:118:18:118:19 | 42 | Superfluous argument passed to $@. | tst.js:102:2:110:2 | functio ... )();\\n\\t} | function throwerIndirect |
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/SpuriousArguments.qlref b/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/SpuriousArguments.qlref
index f148cdba2ece..2c48d9faefb0 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/SpuriousArguments.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/SpuriousArguments.qlref
@@ -1 +1,2 @@
-LanguageFeatures/SpuriousArguments.ql
\ No newline at end of file
+query: LanguageFeatures/SpuriousArguments.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/es2015.js b/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/es2015.js
index 928edcd7fd3e..07f4446800b0 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/es2015.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/es2015.js
@@ -1,7 +1,7 @@
class Class1 {
constructor(x) { this.x = x; }
}
-new Class1(42, 23); // NOT OK: `23` is ignored
+new Class1(42, 23); // $ Alert - `23` is ignored
class Sup {
constructor(x) { this.x = x; }
@@ -10,12 +10,12 @@ class Sup {
class Sub extends Sup {
}
-new Sub(42); // OK: synthetic constructor delegates to super constructor
+new Sub(42); // OK - synthetic constructor delegates to super constructor
class Other {}
-new Other(42); // NOT OK: `42` is ignored
+new Other(42); // $ Alert - `42` is ignored
var args = [];
-f(...args); // OK
-f(42, ...args); // NOT OK
\ No newline at end of file
+f(...args);
+f(42, ...args); // $ Alert
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/globals.js b/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/globals.js
index 3771a18ed876..e41ddd2d0136 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/globals.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/globals.js
@@ -4,7 +4,7 @@ function global() {return;}
window.global = function (x) {return;};
})(this);
-global(x); // OK: might refer to function on line 4
+global(x); // OK - might refer to function on line 4
function otherglobal() {return;}
@@ -12,6 +12,6 @@ var o = {
otherglobal: function (x) {return;}
};
-otherglobal(x); // NOT OK: can never refer to function on line 12
-otherglobal.call(null, x); // NOT OK
-otherglobal.call(null, x, y); // NOT OK
+otherglobal(x); // $ Alert - can never refer to function on line 12
+otherglobal.call(null, x); // $ Alert
+otherglobal.call(null, x, y); // $ Alert
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/reflection.js b/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/reflection.js
index 22c8c3b537e7..ac2df0dafdce 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/reflection.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/reflection.js
@@ -3,13 +3,13 @@ function f1(x) {return;}
f0.call();
f0.call(this);
-f0.call(this, 1);
-f0.call(this, 1, 2);
+f0.call(this, 1); // $ Alert
+f0.call(this, 1, 2); // $ Alert
f1.call();
f1.call(this);
f1.call(this, 1);
-f1.call(this, 1, 2);
+f1.call(this, 1, 2); // $ Alert
f0.apply();
f0.apply(this);
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/thisparameter.ts b/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/thisparameter.ts
index d166c957858e..d17b5d33459f 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/thisparameter.ts
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/thisparameter.ts
@@ -1,4 +1,4 @@
function foo(this: void, x: number) {return;}
-foo(45); // OK
-foo(null, 45); // NOT OK
+foo(45);
+foo(null, 45); // $ Alert
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/tst.js b/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/tst.js
index 1caa88564a1a..387348232e3d 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/tst.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SpuriousArguments/tst.js
@@ -7,8 +7,7 @@ function g() {
return 23;
}
-// NOT OK
-f(g());
+f(g()); // $ Alert
function sum() {
var result = 0;
@@ -17,33 +16,31 @@ function sum() {
return result;
}
-// OK
+
sum(1, 2, 3);
function h(k) {
k = k || function() {};
- // OK
+
k(42);
}
-// OK
+
new Array(1, 2, 3);
-// NOT OK
-new String(1, 2, 3);
+new String(1, 2, 3); // $ Alert
(function(f) {
- // NOT OK
- f(42);
+ f(42); // $ Alert
})(function() {return;});
(function h(f) {
- // OK
+
f(42);
h(function(x) { return x; });
})(function() {});
-parseFloat("123", 10);
+parseFloat("123", 10); // $ Alert - unlike parseInt this does not take a radix
(function testWhitelistEmptyFunctions(){
function nonEmpty(){
@@ -67,15 +64,15 @@ parseFloat("123", 10);
constructor(){
}
}
- nonEmpty(42); // NOT OK
- empty(42); // OK
- emptyWithParam(42, 87); // OK
- commentedEmpty(42); // OK
- commentedEmptyWithSpreadParam(42, 87); // OK
- emptyArrow(42); // NOT OK
- new ImplicitEmptyConstructor(42); // NOT OK
- new ExplicitEmptyConstructor(42); // NOT OK
- parseFloat("123", 10); // NOT OK
+ nonEmpty(42); // $ Alert
+ empty(42);
+ emptyWithParam(42, 87);
+ commentedEmpty(42);
+ commentedEmptyWithSpreadParam(42, 87);
+ emptyArrow(42); // $ Alert
+ new ImplicitEmptyConstructor(42); // $ Alert
+ new ExplicitEmptyConstructor(42); // $ Alert
+ parseFloat("123", 10); // $ Alert
});
(function testWhitelistThrowingFunctions() {
@@ -111,14 +108,14 @@ parseFloat("123", 10);
}
})();
}
- notAPlainThrower1(42); // NOT OK
- notAPlainThrower2(42); // NOT OK
- notAPlainThrower3(42); // NOT OK
- thrower(42); // OK
- throwerArrow(42); // OK
- throwerCustom(42); // OK
- throwerWithParam(42, 87); // NOT OK
- throwerIndirect(42); // OK, but still flagged due to complexity
+ notAPlainThrower1(42); // $ Alert
+ notAPlainThrower2(42); // $ Alert
+ notAPlainThrower3(42); // $ Alert
+ thrower(42);
+ throwerArrow(42);
+ throwerCustom(42);
+ throwerWithParam(42, 87); // $ Alert
+ throwerIndirect(42); // $ SPURIOUS: Alert - flagged due to complexity
});
function sum2() {
@@ -128,14 +125,14 @@ function sum2() {
return result;
}
-// OK
+
sum2(1, 2, 3);
const $ = function (x, arr) {
console.log(x, arr);
};
-// OK
+
async function tagThing(repoUrl, directory) {
await $`git clone ${repoUrl} ${directory}`;
}
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/StrictModeCallStackIntrospection/StrictModeCallStackIntrospection.expected b/javascript/ql/test/query-tests/LanguageFeatures/StrictModeCallStackIntrospection/StrictModeCallStackIntrospection.expected
index 967ac1ce58f3..7141c9d5589e 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/StrictModeCallStackIntrospection/StrictModeCallStackIntrospection.expected
+++ b/javascript/ql/test/query-tests/LanguageFeatures/StrictModeCallStackIntrospection/StrictModeCallStackIntrospection.expected
@@ -1,7 +1,7 @@
-| tst.js:5:30:5:45 | arguments.callee | Strict mode code cannot use arguments.callee. |
-| tst.js:7:21:7:36 | arguments.callee | Strict mode code cannot use arguments.callee. |
-| tst.js:9:20:9:27 | f.caller | Strict mode code cannot use Function.prototype.caller. |
-| tst.js:11:17:11:27 | f.arguments | Strict mode code cannot use Function.prototype.arguments. |
-| tst.js:18:10:18:25 | arguments.callee | Strict mode code cannot use arguments.callee. |
-| tst.js:31:12:31:21 | foo.caller | Strict mode code cannot use Function.prototype.caller. |
-| tst.js:31:12:31:21 | foo.caller | Strict mode code cannot use arguments.caller. |
+| tst.js:4:30:4:45 | arguments.callee | Strict mode code cannot use arguments.callee. |
+| tst.js:5:21:5:36 | arguments.callee | Strict mode code cannot use arguments.callee. |
+| tst.js:6:20:6:27 | f.caller | Strict mode code cannot use Function.prototype.caller. |
+| tst.js:7:17:7:27 | f.arguments | Strict mode code cannot use Function.prototype.arguments. |
+| tst.js:13:10:13:25 | arguments.callee | Strict mode code cannot use arguments.callee. |
+| tst.js:25:12:25:21 | foo.caller | Strict mode code cannot use Function.prototype.caller. |
+| tst.js:25:12:25:21 | foo.caller | Strict mode code cannot use arguments.caller. |
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/StrictModeCallStackIntrospection/StrictModeCallStackIntrospection.qlref b/javascript/ql/test/query-tests/LanguageFeatures/StrictModeCallStackIntrospection/StrictModeCallStackIntrospection.qlref
index d093603e0779..92a121e2099c 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/StrictModeCallStackIntrospection/StrictModeCallStackIntrospection.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/StrictModeCallStackIntrospection/StrictModeCallStackIntrospection.qlref
@@ -1 +1,2 @@
-LanguageFeatures/StrictModeCallStackIntrospection.ql
\ No newline at end of file
+query: LanguageFeatures/StrictModeCallStackIntrospection.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/StrictModeCallStackIntrospection/tst.js b/javascript/ql/test/query-tests/LanguageFeatures/StrictModeCallStackIntrospection/tst.js
index 583daac6ccca..6965cab8bae0 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/StrictModeCallStackIntrospection/tst.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/StrictModeCallStackIntrospection/tst.js
@@ -1,25 +1,20 @@
var o = {
A: function f(x) {
'use strict';
- // BAD
- if (!(this instanceof arguments.callee))
- // BAD
- return new arguments.callee(x);
- // BAD
- console.log(f.caller);
- // BAD
- this.y = f.arguments;
+ if (!(this instanceof arguments.callee)) // $ Alert
+ return new arguments.callee(x); // $ Alert
+ console.log(f.caller); // $ Alert
+ this.y = f.arguments; // $ Alert
this.x = x;
}
};
var D = class extends function() {
- // BAD
- return arguments.callee;
+ return arguments.callee; // $ Alert
} {};
function g() {
- // OK
+
return arguments.caller.length;
}
@@ -27,8 +22,7 @@ function g() {
'use strict';
function h() {
var foo = Math.random() > 0.5 ? h : arguments;
- // BAD
- return foo.caller;
+ return foo.caller; // $ Alert
}
})();
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/SyntaxError.qlref b/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/SyntaxError.qlref
index 33bc1d9e3b45..4133f6e98314 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/SyntaxError.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/SyntaxError.qlref
@@ -1 +1 @@
-LanguageFeatures/SyntaxError.ql
+query: LanguageFeatures/SyntaxError.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/arrows.js b/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/arrows.js
index 62468802e464..ce50894cacea 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/arrows.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/arrows.js
@@ -1 +1 @@
-(a, a) => a + a;
+(a, a) => a + a; // $ Alert
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/destructingPrivate.js b/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/destructingPrivate.js
index 060111d86b46..4edd6cb2d6f9 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/destructingPrivate.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/destructingPrivate.js
@@ -1,6 +1,6 @@
class C {
#privDecl;
bar() {
- {#privDecl} = this;
+ {#privDecl} = this; // $ Alert
}
}
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/tst.js b/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/tst.js
index e7aaa89f128a..62acf99f0477 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/tst.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/tst.js
@@ -1,2 +1,2 @@
function findBox() {
- return $("box.important
+ return $("box.important // $ Alert
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/TemplateSyntaxInStringLiteral/TemplateSyntaxInStringLiteral.js b/javascript/ql/test/query-tests/LanguageFeatures/TemplateSyntaxInStringLiteral/TemplateSyntaxInStringLiteral.js
index 65a61da7a616..d21a662dc5e8 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/TemplateSyntaxInStringLiteral/TemplateSyntaxInStringLiteral.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/TemplateSyntaxInStringLiteral/TemplateSyntaxInStringLiteral.js
@@ -2,7 +2,7 @@ function connectAndLog(id) {
log.info(`Connecting to ${id}`)
let connection = openConnection(id)
if (!connection) {
- log.error('Could not connect to ${id}')
+ log.error('Could not connect to ${id}') // $ Alert
}
}
@@ -14,9 +14,9 @@ function emitTemplate(name, date) {
var globalVar = "global";
function foo() {
- log.error('globalVar = ${globalVar}');
+ log.error('globalVar = ${globalVar}'); // $ Alert
}
-log.error('globalVar = ${globalVar}');
+log.error('globalVar = ${globalVar}'); // $ Alert
function bar() {
log.error('Something ${notInScope}');
@@ -25,7 +25,7 @@ function bar() {
function baz(x){
log.error("${x}");
log.error("${y}");
- log.error("${x} ");
+ log.error("${x} "); // $ Alert
log.error("${y} ");
}
@@ -37,7 +37,7 @@ function foo1() {
const foobar = 4;
const data = {name: name, date: date};
- writer.emit("Name: ${name}, Date: ${date}.", data); // OK
+ writer.emit("Name: ${name}, Date: ${date}.", data);
- writer.emit("Name: ${name}, Date: ${date}, ${foobar}", data); // NOT OK - `foobar` is not in `data`.
+ writer.emit("Name: ${name}, Date: ${date}, ${foobar}", data); // $ Alert - `foobar` is not in `data`.
}
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/TemplateSyntaxInStringLiteral/TemplateSyntaxInStringLiteral.qlref b/javascript/ql/test/query-tests/LanguageFeatures/TemplateSyntaxInStringLiteral/TemplateSyntaxInStringLiteral.qlref
index 372cdfd68f5d..6eb187fa573a 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/TemplateSyntaxInStringLiteral/TemplateSyntaxInStringLiteral.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/TemplateSyntaxInStringLiteral/TemplateSyntaxInStringLiteral.qlref
@@ -1 +1,2 @@
-LanguageFeatures/TemplateSyntaxInStringLiteral.ql
+query: LanguageFeatures/TemplateSyntaxInStringLiteral.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/ThisBeforeSuper/ThisBeforeSuper.expected b/javascript/ql/test/query-tests/LanguageFeatures/ThisBeforeSuper/ThisBeforeSuper.expected
index e4a1e1a53dff..dbc274d613c1 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/ThisBeforeSuper/ThisBeforeSuper.expected
+++ b/javascript/ql/test/query-tests/LanguageFeatures/ThisBeforeSuper/ThisBeforeSuper.expected
@@ -10,5 +10,5 @@
| invalid.js:14:35:14:118 | () { cl ... er(); } | The super constructor must be called before using $@. | invalid.js:14:99:14:102 | this | this |
| invalid.js:15:71:15:95 | () { th ... er(); } | The super constructor must be called before using $@. | invalid.js:15:76:15:79 | this | this |
| invalid.js:16:35:16:66 | () { if ... .a(); } | The super constructor must be called before using $@. | invalid.js:16:56:16:59 | this | this |
-| invalid.js:26:16:26:19 | () {\\n ... ;\\n } | The super constructor must be called before using $@. | invalid.js:27:9:27:12 | this | this |
-| invalid.js:26:16:26:19 | () {\\n ... ;\\n } | The super constructor must be called before using $@. | invalid.js:28:9:28:12 | this | this |
+| invalid.js:26:16:26:30 | () { // ... ;\\n } | The super constructor must be called before using $@. | invalid.js:27:9:27:12 | this | this |
+| invalid.js:26:16:26:30 | () { // ... ;\\n } | The super constructor must be called before using $@. | invalid.js:28:9:28:12 | this | this |
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/ThisBeforeSuper/ThisBeforeSuper.qlref b/javascript/ql/test/query-tests/LanguageFeatures/ThisBeforeSuper/ThisBeforeSuper.qlref
index f755c5a9d472..0d3e717fe79a 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/ThisBeforeSuper/ThisBeforeSuper.qlref
+++ b/javascript/ql/test/query-tests/LanguageFeatures/ThisBeforeSuper/ThisBeforeSuper.qlref
@@ -1 +1,2 @@
-LanguageFeatures/ThisBeforeSuper.ql
\ No newline at end of file
+query: LanguageFeatures/ThisBeforeSuper.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/ThisBeforeSuper/invalid.js b/javascript/ql/test/query-tests/LanguageFeatures/ThisBeforeSuper/invalid.js
index 82e7f8cda77e..c70e2cdcf7f1 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/ThisBeforeSuper/invalid.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/ThisBeforeSuper/invalid.js
@@ -2,18 +2,18 @@
// under the MIT license; see file LICENSE.
class B1 {}
-class A30 extends B1 { constructor() { this.c = 0; } }
-class A31 extends B1 { constructor() { this.c(); } }
-class A32 extends B1 { constructor() { super.c(); } }
-class A33 extends B1 { constructor() { this.c = 0; super(); } }
-class A34 extends B1 { constructor() { this.c(); super(); } }
-class A35 extends B1 { constructor() { super.c(); super(); } }
-class A36 extends B1 { constructor() { super(this.c); } }
-class A37 extends B1 { constructor() { super(this.c()); } }
-class A38 extends B1 { constructor() { super(super.c()); } }
-class A39 extends B1 { constructor() { class C extends D { constructor() { super(); this.e(); } } this.f(); super(); } }
-class A40 extends B1 { constructor() { class C extends D { constructor() { this.e(); super(); } } super(); this.f(); } }
-class A41 extends B1 { constructor() { if (a) super(); this.a(); } }
+class A30 extends B1 { constructor() { this.c = 0; } } // $ Alert
+class A31 extends B1 { constructor() { this.c(); } } // $ Alert
+class A32 extends B1 { constructor() { super.c(); } } // $ Alert
+class A33 extends B1 { constructor() { this.c = 0; super(); } } // $ Alert
+class A34 extends B1 { constructor() { this.c(); super(); } } // $ Alert
+class A35 extends B1 { constructor() { super.c(); super(); } } // $ Alert
+class A36 extends B1 { constructor() { super(this.c); } } // $ Alert
+class A37 extends B1 { constructor() { super(this.c()); } } // $ Alert
+class A38 extends B1 { constructor() { super(super.c()); } } // $ Alert
+class A39 extends B1 { constructor() { class C extends D { constructor() { super(); this.e(); } } this.f(); super(); } } // $ Alert
+class A40 extends B1 { constructor() { class C extends D { constructor() { this.e(); super(); } } super(); this.f(); } } // $ Alert
+class A41 extends B1 { constructor() { if (a) super(); this.a(); } } // $ Alert
// the following two cases are not currently detected (even though they should be):
// while `this` is, in both cases, guarded by a `super` call, the call does not complete
@@ -23,7 +23,7 @@ class A42 extends B2 { constructor() { try { super(); } finally { this.a; } } }
class A43 extends B2 { constructor() { try { super(); } catch (err) { } this.a; } }
class A44 extends B1 {
- constructor() {
+ constructor() { // $ Alert
this.p1 = 0;
this.p2 = 0;
}
diff --git a/javascript/ql/test/query-tests/LanguageFeatures/UnusedIndexVariable/UnusedIndexVariable.js b/javascript/ql/test/query-tests/LanguageFeatures/UnusedIndexVariable/UnusedIndexVariable.js
index 7f6071b86963..7d139a4d582c 100644
--- a/javascript/ql/test/query-tests/LanguageFeatures/UnusedIndexVariable/UnusedIndexVariable.js
+++ b/javascript/ql/test/query-tests/LanguageFeatures/UnusedIndexVariable/UnusedIndexVariable.js
@@ -1,6 +1,6 @@
function sum(xs) {
var res = 0;
- for(var i=0; i
| |
+| selfimport.js:1:1:1:23 | require ... mport') | Module selfimport directly imports itself. | selfimport.js:1:1:1:35 | | |
| test1/a.js:1:1:1:27 | require ... ner/a') | Module /test1/a.js imports module .../inner/a.js, which in turn $@ it. | test2/inner/a.js:1:1:1:24 | require ... st1/a') | imports |
| test1/a.js:2:1:2:14 | require('./b') | Module a imports module b, which in turn $@ it. | test1/b.js:1:1:1:27 | require ... ner/a') | indirectly imports |
| test1/b.js:1:1:1:27 | require ... ner/a') | Module b imports module a, which in turn $@ it. | test2/inner/a.js:1:1:1:24 | require ... st1/a') | indirectly imports |
diff --git a/javascript/ql/test/query-tests/NodeJS/CyclicImport/CyclicImport.qlref b/javascript/ql/test/query-tests/NodeJS/CyclicImport/CyclicImport.qlref
index 944a1f16d023..2f1ba00da9b5 100644
--- a/javascript/ql/test/query-tests/NodeJS/CyclicImport/CyclicImport.qlref
+++ b/javascript/ql/test/query-tests/NodeJS/CyclicImport/CyclicImport.qlref
@@ -1 +1,2 @@
-NodeJS/CyclicImport.ql
\ No newline at end of file
+query: NodeJS/CyclicImport.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/NodeJS/CyclicImport/a.js b/javascript/ql/test/query-tests/NodeJS/CyclicImport/a.js
index 6e20c34bb2ae..e435ffdd6e61 100644
--- a/javascript/ql/test/query-tests/NodeJS/CyclicImport/a.js
+++ b/javascript/ql/test/query-tests/NodeJS/CyclicImport/a.js
@@ -1,7 +1,7 @@
// Adapted from the Node.js documentation
console.log('a starting');
exports.done = false;
-var b = require('./b.js');
+var b = require('./b.js'); // $ Alert
console.log('in a, b.done = %j', b.done);
exports.done = true;
console.log('a done');
diff --git a/javascript/ql/test/query-tests/NodeJS/CyclicImport/b.js b/javascript/ql/test/query-tests/NodeJS/CyclicImport/b.js
index 48d00da05eec..b8b1b26c76a8 100644
--- a/javascript/ql/test/query-tests/NodeJS/CyclicImport/b.js
+++ b/javascript/ql/test/query-tests/NodeJS/CyclicImport/b.js
@@ -1,7 +1,7 @@
// Adapted from the Node.js documentation
console.log('b starting');
exports.done = false;
-var a = require('./a.js');
+var a = require('./a.js'); // $ Alert
console.log('in b, a.done = %j', a.done);
exports.done = true;
console.log('b done');
diff --git a/javascript/ql/test/query-tests/NodeJS/CyclicImport/selfimport.js b/javascript/ql/test/query-tests/NodeJS/CyclicImport/selfimport.js
index 524cd7785c61..015dd055baa7 100644
--- a/javascript/ql/test/query-tests/NodeJS/CyclicImport/selfimport.js
+++ b/javascript/ql/test/query-tests/NodeJS/CyclicImport/selfimport.js
@@ -1 +1 @@
-require('./selfimport');
\ No newline at end of file
+require('./selfimport'); // $ Alert
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/NodeJS/CyclicImport/test1/a.js b/javascript/ql/test/query-tests/NodeJS/CyclicImport/test1/a.js
index c50b18df78a5..19e985960836 100644
--- a/javascript/ql/test/query-tests/NodeJS/CyclicImport/test1/a.js
+++ b/javascript/ql/test/query-tests/NodeJS/CyclicImport/test1/a.js
@@ -1,2 +1,2 @@
-require('../test2/inner/a');
-require('./b');
\ No newline at end of file
+require('../test2/inner/a'); // $ Alert
+require('./b'); // $ Alert
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/NodeJS/CyclicImport/test1/b.js b/javascript/ql/test/query-tests/NodeJS/CyclicImport/test1/b.js
index 4dad3ca3b97f..c1527dc042ca 100644
--- a/javascript/ql/test/query-tests/NodeJS/CyclicImport/test1/b.js
+++ b/javascript/ql/test/query-tests/NodeJS/CyclicImport/test1/b.js
@@ -1 +1 @@
-require('../test2/inner/a');
\ No newline at end of file
+require('../test2/inner/a'); // $ Alert
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/NodeJS/CyclicImport/test2/inner/a.js b/javascript/ql/test/query-tests/NodeJS/CyclicImport/test2/inner/a.js
index c96937e40a33..cc49a519bc0d 100644
--- a/javascript/ql/test/query-tests/NodeJS/CyclicImport/test2/inner/a.js
+++ b/javascript/ql/test/query-tests/NodeJS/CyclicImport/test2/inner/a.js
@@ -1 +1 @@
-require('../../test1/a');
\ No newline at end of file
+require('../../test1/a'); // $ Alert
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/NodeJS/DubiousImport/DubiousImport.qlref b/javascript/ql/test/query-tests/NodeJS/DubiousImport/DubiousImport.qlref
index 6b556de9f00b..c6005b442606 100644
--- a/javascript/ql/test/query-tests/NodeJS/DubiousImport/DubiousImport.qlref
+++ b/javascript/ql/test/query-tests/NodeJS/DubiousImport/DubiousImport.qlref
@@ -1 +1,2 @@
-NodeJS/DubiousImport.ql
\ No newline at end of file
+query: NodeJS/DubiousImport.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/NodeJS/DubiousImport/a.js b/javascript/ql/test/query-tests/NodeJS/DubiousImport/a.js
index 2c75ba0124ff..c0c95c0d5f67 100644
--- a/javascript/ql/test/query-tests/NodeJS/DubiousImport/a.js
+++ b/javascript/ql/test/query-tests/NodeJS/DubiousImport/a.js
@@ -1,4 +1,4 @@
-var foo = require('./b').foo,
+var foo = require('./b').foo, // $ Alert
bar = require('./c').bar,
sneaky = require('./d').sneaky;
diff --git a/javascript/ql/test/query-tests/NodeJS/DubiousImport/main.js b/javascript/ql/test/query-tests/NodeJS/DubiousImport/main.js
index b4645ff98881..6f2bd18a9127 100644
--- a/javascript/ql/test/query-tests/NodeJS/DubiousImport/main.js
+++ b/javascript/ql/test/query-tests/NodeJS/DubiousImport/main.js
@@ -2,7 +2,7 @@ var b = require('./b'),
c = require('./c'),
d = require('./d');
-b.foo;
+b.foo; // $ Alert
c.bar;
d.sneaky;
b.prototype;
@@ -12,7 +12,7 @@ require('./f').tricky;
var fs = require('fs');
fs.rename('foo', 'bar', function() {});
-fs.renmae('foo', 'bar', function() {});
+fs.renmae('foo', 'bar', function() {}); // $ Alert
fs.move('foo', 'bar', function() {});
var k = require('./k');
@@ -20,7 +20,7 @@ k.foo;
var l = require('./l');
l.foo();
-l.bar(); // not OK
+l.bar(); // $ Alert
require('./m').foo;
diff --git a/javascript/ql/test/query-tests/NodeJS/DubiousImport/multi_import.js b/javascript/ql/test/query-tests/NodeJS/DubiousImport/multi_import.js
index cacb69772fe9..7eb45e2cfabb 100644
--- a/javascript/ql/test/query-tests/NodeJS/DubiousImport/multi_import.js
+++ b/javascript/ql/test/query-tests/NodeJS/DubiousImport/multi_import.js
@@ -10,10 +10,10 @@ if (cond) {
}
if (cond) {
- mod1.call(); // OK: `mod1` is `./b`, which exports `call`
+ mod1.call(); // OK - `mod1` is `./b`, which exports `call`
} else {
- mod1.bar; // OK: `mod1` is `./c`, which exports `bar`
- mod2.bar; // NOT OK: `mod2` is `./b`, which does not export `call`
+ mod1.bar; // OK - `mod1` is `./c`, which exports `bar`
+ mod2.bar; // $ Alert - `mod2` is `./b`, which does not export `call`
}
module.exports = {};
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/NodeJS/InvalidExport/InvalidExport.qlref b/javascript/ql/test/query-tests/NodeJS/InvalidExport/InvalidExport.qlref
index 6864d74ec268..5225f0d052a9 100644
--- a/javascript/ql/test/query-tests/NodeJS/InvalidExport/InvalidExport.qlref
+++ b/javascript/ql/test/query-tests/NodeJS/InvalidExport/InvalidExport.qlref
@@ -1 +1,2 @@
-NodeJS/InvalidExport.ql
\ No newline at end of file
+query: NodeJS/InvalidExport.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst.js b/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst.js
index 83bd3009a8ba..61a2663a7ad6 100644
--- a/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst.js
+++ b/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst.js
@@ -1,2 +1,2 @@
-exports.a = 23; // OK
-exports = 56; // NOT OK
+exports.a = 23;
+exports = 56; // $ Alert
diff --git a/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst2a.js b/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst2a.js
index c650950972b5..f02b2cdaa4f7 100644
--- a/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst2a.js
+++ b/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst2a.js
@@ -1,3 +1,3 @@
-// OK: use of `exports` as shorthand for `module.exports`
+// OK - use of `exports` as shorthand for `module.exports`
exports = module.exports = {};
exports.a = 23;
diff --git a/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst2b.js b/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst2b.js
index 67a979faef7a..f3c20feff45f 100644
--- a/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst2b.js
+++ b/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst2b.js
@@ -1,3 +1,3 @@
-// OK: use of `exports` as shorthand for `module.exports`
+// OK - use of `exports` as shorthand for `module.exports`
module.exports = exports = {};
exports.a = 23;
diff --git a/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst2c.js b/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst2c.js
index 18089f129a6e..d7269a450093 100644
--- a/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst2c.js
+++ b/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst2c.js
@@ -1,4 +1,4 @@
-// OK: use of `exports` as shorthand for `module.exports`
+// OK - use of `exports` as shorthand for `module.exports`
exports = {};
exports.a = 23;
module.exports = exports;
diff --git a/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst3.js b/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst3.js
index 93448cd102f9..78ea98c06292 100644
--- a/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst3.js
+++ b/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst3.js
@@ -1,2 +1,2 @@
-// OK: useless assignment flagged by other query
+// OK - useless assignment flagged by other query
exports = module.exports = { a: 23 };
diff --git a/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst3b.js b/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst3b.js
index 679437bd5b9d..e638381c2690 100644
--- a/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst3b.js
+++ b/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst3b.js
@@ -1,2 +1,2 @@
-// OK: useless assignment flagged by other query
+// OK - useless assignment flagged by other query
module.exports = exports = { a: 23 };
diff --git a/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst4.js b/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst4.js
index c24fd42b6dd9..2a5f22cb49d8 100644
--- a/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst4.js
+++ b/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst4.js
@@ -1,2 +1,2 @@
-module.exports.a = 23; // OK
-module.exports = 56; // OK
+module.exports.a = 23;
+module.exports = 56;
diff --git a/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst5.js b/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst5.js
index 4b93bb8f7f40..9361a968088c 100644
--- a/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst5.js
+++ b/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst5.js
@@ -1,4 +1,4 @@
module.exports = exports;
-exports = {}; // NOT OK, reassignment above should appear below
+exports = {}; // $ Alert - reassignment above should appear below
exports.a = 12;
diff --git a/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst6.js b/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst6.js
index d91971d6f519..cf5eb12ff0ac 100644
--- a/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst6.js
+++ b/javascript/ql/test/query-tests/NodeJS/InvalidExport/tst6.js
@@ -1,4 +1,4 @@
var e = {};
module.exports = e;
-exports = e; // OK
+exports = e;
exports.a = 12;
diff --git a/javascript/ql/test/query-tests/NodeJS/MissingExports/MissingExports.js b/javascript/ql/test/query-tests/NodeJS/MissingExports/MissingExports.js
index 091cf6fef202..bd8d05fcd03a 100644
--- a/javascript/ql/test/query-tests/NodeJS/MissingExports/MissingExports.js
+++ b/javascript/ql/test/query-tests/NodeJS/MissingExports/MissingExports.js
@@ -4,5 +4,5 @@ exports.checkOne = function(x) {
var checkList = exports.checkList = function(xs) {
for (var i=0; iHello {this.props.name};
}
});
diff --git a/javascript/ql/test/query-tests/React/DirectStateMutation/invalid2.js b/javascript/ql/test/query-tests/React/DirectStateMutation/invalid2.js
index c790106ba3e1..4c87a1f8b0db 100644
--- a/javascript/ql/test/query-tests/React/DirectStateMutation/invalid2.js
+++ b/javascript/ql/test/query-tests/React/DirectStateMutation/invalid2.js
@@ -1,6 +1,6 @@
var Hello = React.createClass({
render: function() {
- this.state.person.name= "bar"
+ this.state.person.name= "bar" // $ Alert
return
;
}
});
diff --git a/javascript/ql/test/query-tests/React/DirectStateMutation/invalid3.js b/javascript/ql/test/query-tests/React/DirectStateMutation/invalid3.js
index 291e0044bb3c..e542b14ce357 100644
--- a/javascript/ql/test/query-tests/React/DirectStateMutation/invalid3.js
+++ b/javascript/ql/test/query-tests/React/DirectStateMutation/invalid3.js
@@ -1,6 +1,6 @@
var Hello = React.createClass({
render: function() {
- this.state.person.name.first = "bar"
+ this.state.person.name.first = "bar" // $ Alert
return
;
}
});
diff --git a/javascript/ql/test/query-tests/React/DirectStateMutation/invalid4.js b/javascript/ql/test/query-tests/React/DirectStateMutation/invalid4.js
index 1b9da154358a..6297f138f002 100644
--- a/javascript/ql/test/query-tests/React/DirectStateMutation/invalid4.js
+++ b/javascript/ql/test/query-tests/React/DirectStateMutation/invalid4.js
@@ -1,7 +1,7 @@
var Hello = React.createClass({
render: function() {
- this.state.person.name.first = "bar"
- this.state.person.name.last = "baz"
+ this.state.person.name.first = "bar" // $ Alert
+ this.state.person.name.last = "baz" // $ Alert
return
;
}
});
diff --git a/javascript/ql/test/query-tests/React/DirectStateMutation/invalid5.js b/javascript/ql/test/query-tests/React/DirectStateMutation/invalid5.js
index fafcb3600a52..0e112ccd74a7 100644
--- a/javascript/ql/test/query-tests/React/DirectStateMutation/invalid5.js
+++ b/javascript/ql/test/query-tests/React/DirectStateMutation/invalid5.js
@@ -3,7 +3,7 @@
var Hello = React.createClass({
render: function() {
var that = this;
- that.state.person.name.first = "bar"
+ that.state.person.name.first = "bar" // $ Alert
return
;
}
});
diff --git a/javascript/ql/test/query-tests/React/DirectStateMutation/invalid6.js b/javascript/ql/test/query-tests/React/DirectStateMutation/invalid6.js
index 9b88b1786b88..fc4e02c5368a 100644
--- a/javascript/ql/test/query-tests/React/DirectStateMutation/invalid6.js
+++ b/javascript/ql/test/query-tests/React/DirectStateMutation/invalid6.js
@@ -2,6 +2,6 @@ class Component extends React.Component {
constructor(props) {
super(props);
this.state = {};
- this.updater = () => this.state.title = 'new title';
+ this.updater = () => this.state.title = 'new title'; // $ Alert
}
}
diff --git a/javascript/ql/test/query-tests/React/DirectStateMutation/invalid7.js b/javascript/ql/test/query-tests/React/DirectStateMutation/invalid7.js
index 6393da58469f..23ce21fbca64 100644
--- a/javascript/ql/test/query-tests/React/DirectStateMutation/invalid7.js
+++ b/javascript/ql/test/query-tests/React/DirectStateMutation/invalid7.js
@@ -2,6 +2,6 @@ class Component extends React.Component {
constructor(props) {
super(props);
this.state = {};
- this.updater = function(){this.state.title = 'new title';};
+ this.updater = function(){this.state.title = 'new title';}; // $ Alert
}
}
diff --git a/javascript/ql/test/query-tests/React/InconsistentStateUpdate/InconsistentStateUpdate.qlref b/javascript/ql/test/query-tests/React/InconsistentStateUpdate/InconsistentStateUpdate.qlref
index bab216c48331..eed73b7bfa4c 100644
--- a/javascript/ql/test/query-tests/React/InconsistentStateUpdate/InconsistentStateUpdate.qlref
+++ b/javascript/ql/test/query-tests/React/InconsistentStateUpdate/InconsistentStateUpdate.qlref
@@ -1 +1,2 @@
-React/InconsistentStateUpdate.ql
\ No newline at end of file
+query: React/InconsistentStateUpdate.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/React/InconsistentStateUpdate/tst.js b/javascript/ql/test/query-tests/React/InconsistentStateUpdate/tst.js
index 835818f144d7..0c73d7ef0772 100644
--- a/javascript/ql/test/query-tests/React/InconsistentStateUpdate/tst.js
+++ b/javascript/ql/test/query-tests/React/InconsistentStateUpdate/tst.js
@@ -1,7 +1,7 @@
class C1 extends React.Component {
upd8() {
this.setState({
- counter: this.state.counter + 1 // NOT OK, but ignored because it is safe in practice
+ counter: this.state.counter + 1 // OK - ignored because it is safe in practice
});
}
}
@@ -9,7 +9,7 @@ class C1 extends React.Component {
class C2 extends React.Component {
upd8() {
this.setState((prevState) => {
- counter: prevState.counter + 1 // OK
+ counter: prevState.counter + 1
});
}
}
@@ -18,7 +18,7 @@ class C3 extends React.Component {
upd8() {
var app = this;
app.setState({
- counter: this.state.counter + 1 // NOT OK, but ignored because it is safe in practice
+ counter: this.state.counter + 1 // OK - ignored because it is safe in practice
});
}
}
@@ -26,73 +26,73 @@ class C3 extends React.Component {
class C4 extends React.Component {
upd8() {
this.setState({
- counter: this.state.foo // NOT OK
- });
+ counter: this.state.foo
+ }); // $ Alert
}
}
class C5 extends React.Component {
upd8() {
this.setState({
- foo: { bar: this.state.foo.bar } // NOT OK
- });
+ foo: { bar: this.state.foo.bar }
+ }); // $ Alert
}
}
class C7 extends React.Component {
upd8a() {
this.setState({
- foo: this.state.foo // NOT OK
- });
+ foo: this.state.foo
+ }); // $ Alert
}
upd8b() {
this.setState({
- foo: this.state.foo // NOT OK
- });
+ foo: this.state.foo
+ }); // $ Alert
}
}
class C8 extends React.Component {
upd8a() {
this.setState({
- foo: this.state.foo + 1 // NOT OK
- });
+ foo: this.state.foo + 1
+ }); // $ Alert
}
upd8b() {
this.setState({
- foo: this.state.foo + 1 // NOT OK
- });
+ foo: this.state.foo + 1
+ }); // $ Alert
}
}
class C9 extends React.Component {
upd8a() {
this.setState({
- foo: { bar: this.state.foo.bar } // NOT OK
- });
+ foo: { bar: this.state.foo.bar }
+ }); // $ Alert
}
upd8b() {
this.setState({
- foo: { bar: this.state.foo.bar } // NOT OK
- });
+ foo: { bar: this.state.foo.bar }
+ }); // $ Alert
}
}
class C10 extends React.Component {
upd8a() {
this.setState({
- foo: this.state.foo, // NOT OK
- bar: this.state.bar // NOT OK, but ignored because it is safe in practice
- });
+ foo: this.state.foo,
+ bar: this.state.bar // OK - ignored because it is safe in practice
+ }); // $ Alert
}
upd8b() {
this.setState({
- foo: this.state.foo // NOT OK
- });
+ foo: this.state.foo
+ }); // $ Alert
}
}
@@ -100,13 +100,13 @@ class C11 extends React.Component {
upd8a() {
var self = this;
self.setState({
- foo: self.state.foo // NOT OK
- });
+ foo: self.state.foo
+ }); // $ Alert
}
upd8b() {
this.setState({
- foo: this.state.foo // NOT OK
- });
+ foo: this.state.foo
+ }); // $ Alert
}
}
diff --git a/javascript/ql/test/query-tests/React/UnsupportedStateUpdateInLifecycleMethod/UnsupportedStateUpdateInLifecycleMethod.qlref b/javascript/ql/test/query-tests/React/UnsupportedStateUpdateInLifecycleMethod/UnsupportedStateUpdateInLifecycleMethod.qlref
index dfa6c80426f6..9d1de0e203a6 100644
--- a/javascript/ql/test/query-tests/React/UnsupportedStateUpdateInLifecycleMethod/UnsupportedStateUpdateInLifecycleMethod.qlref
+++ b/javascript/ql/test/query-tests/React/UnsupportedStateUpdateInLifecycleMethod/UnsupportedStateUpdateInLifecycleMethod.qlref
@@ -1 +1,2 @@
-React/UnsupportedStateUpdateInLifecycleMethod.ql
\ No newline at end of file
+query: React/UnsupportedStateUpdateInLifecycleMethod.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/React/UnsupportedStateUpdateInLifecycleMethod/tst.js b/javascript/ql/test/query-tests/React/UnsupportedStateUpdateInLifecycleMethod/tst.js
index f3c488d38b62..41dcc713ceb1 100644
--- a/javascript/ql/test/query-tests/React/UnsupportedStateUpdateInLifecycleMethod/tst.js
+++ b/javascript/ql/test/query-tests/React/UnsupportedStateUpdateInLifecycleMethod/tst.js
@@ -1,9 +1,9 @@
// update variants
React.createClass({
render: function() {
- this.setState({}); // NOT OK
- this.replaceState({}); // NOT OK
- this.forceUpdate({}); // NOT OK
+ this.setState({}); // $ Alert
+ this.replaceState({}); // $ Alert
+ this.forceUpdate({}); // $ Alert
return
}
});
@@ -14,8 +14,8 @@ class MyClass1 extends React.Component {
super(props);
}
render() {
- this.indirectUpdate(); // NOT OK
- this.veryIndirectUpdate(); // NOT OK
+ this.indirectUpdate(); // $ Alert
+ this.veryIndirectUpdate(); // $ Alert
return
}
@@ -34,24 +34,24 @@ class MyClass1 extends React.Component {
// definiteness variants
React.createClass({
render: function() {
- this.setState({}); // NOT OK
+ this.setState({}); // $ Alert
},
componentDidUpdate: function() {
- this.setState({}); // NOT OK
+ this.setState({}); // $ Alert
if (cond) {
- this.setState({}); // OK
+ this.setState({});
}
},
shouldComponentUpdate: function() {
- this.setState({}); // NOT OK
+ this.setState({}); // $ Alert
if (cond) {
- this.setState({}); // OK
+ this.setState({});
}
},
componentWillUpdate: function() {
- this.setState({}); // NOT OK
+ this.setState({}); // $ Alert
if (cond) {
- this.setState({}); // OK
+ this.setState({});
}
}
});
@@ -63,11 +63,11 @@ class MyClass2 extends React.Component {
}
componentWillUpdate() {
- this.definiteIndirectUpdate(); // NOT OK
+ this.definiteIndirectUpdate(); // $ Alert
if (cond) {
- this.definiteIndirectUpdate(); // OK
+ this.definiteIndirectUpdate();
}
- this.indefiniteIndirectUpdate(); // OK
+ this.indefiniteIndirectUpdate();
return
}
@@ -86,7 +86,7 @@ class MyClass2 extends React.Component {
React.createClass({
render: function() {
var app = this;
- app.setState({}); // NOT OK
+ app.setState({}); // $ Alert
return
}
});
@@ -97,7 +97,7 @@ React.createClass({
this.setState({})
},
render: function() {
- this.indirectUpdate();
+ this.indirectUpdate(); // $ Alert
return
}
});
@@ -105,9 +105,9 @@ React.createClass({
// eslint examples
React.createClass({
componentDidUpdate: function() {
- this.setState({ // NOT OK
+ this.setState({
name: this.props.name.toUpperCase()
- });
+ }); // $ Alert
},
render: function() {
return
;
@@ -115,9 +115,9 @@ React.createClass({
});
React.createClass({
componentWillUpdate: function() {
- this.setState({ // NOT OK
+ this.setState({
name: this.props.name.toUpperCase()
- });
+ }); // $ Alert
},
render: function() {
return
;
@@ -138,7 +138,7 @@ class Search extends React.Component {
render() {
return (
-
// $ Alert
);
}
}
@@ -147,25 +147,25 @@ class Search extends React.Component {
class MyClass3 extends React.Component {
constructor(props) {
super(props);
- this.setState({}); // NOT OK
+ this.setState({}); // $ Alert
}
componentDidUnmount() {
- this.setState({}); // NOT OK
+ this.setState({}); // $ Alert
}
getDefaultProps() {
- this.setState({}); // NOT OK
+ this.setState({}); // $ Alert
}
getInitialState() {
- this.setState({}); // NOT OK
+ this.setState({}); // $ Alert
}
componentWillUnmount() {
- this.setState({}); // OK
+ this.setState({});
}
componentWillMount() {
- this.setState({}); // OK
+ this.setState({});
}
componentDidMount() {
- this.setState({}); // OK
+ this.setState({});
}
}
@@ -184,8 +184,8 @@ class MyClass4 extends React.Component {
var doUpdate4 = () => this.myUpdate();
doUpdate4();
}
- doUpdate1(); // NOT OK
- doUpdate2(); // NOT OK
- doUpdate3(); // NOT OK
+ doUpdate1(); // $ Alert
+ doUpdate2(); // $ Alert
+ doUpdate3(); // $ Alert
}
}
diff --git a/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/UnusedOrUndefinedStateProperty.expected b/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/UnusedOrUndefinedStateProperty.expected
index fd0b9853a6ac..74825d5a26d8 100644
--- a/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/UnusedOrUndefinedStateProperty.expected
+++ b/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/UnusedOrUndefinedStateProperty.expected
@@ -1,7 +1,7 @@
-| issue7506.js:12:1:12:34 | class C ... e\\n }\\n} | Component state property 'p1' is $@, but it is never read. | issue7506.js:15:5:15:10 | p1: '' | written |
-| undefined.js:1:1:1:34 | class C ... }\\n} | Component state property 'notWritten' is $@, but it is never written. | undefined.js:8:9:8:29 | this.st ... Written | read |
-| undefined.js:1:1:1:34 | class C ... }\\n} | Component state property 'notWrittenButReadInChain' is $@, but it is never written. | undefined.js:9:9:9:43 | this.st ... InChain | read |
-| undefined.js:32:1:32:34 | class C ... }\\n} | Component state property 'notWrittenThrougExternalPropertyAccess' is $@, but it is never written. | undefined.js:35:9:35:57 | this.st ... yAccess | read |
-| undefined.js:61:19:61:19 | {\\n r ... ;\\n }\\n} | Component state property 'notWrittenInKnownInitializerObject' is $@, but it is never written. | undefined.js:64:9:64:53 | this.st ... rObject | read |
-| unused.js:1:1:1:34 | class C ... }\\n} | Component state property 'notRead' is $@, but it is never read. | unused.js:6:9:6:26 | this.state.notRead | written |
-| unused.js:27:1:27:34 | class C ... }\\n} | Component state property 'notReadThrougExternaPropertyAccess' is $@, but it is never read. | unused.js:30:9:30:53 | this.st ... yAccess | written |
+| issue7506.js:12:1:12:45 | class C ... e\\n }\\n} | Component state property 'p1' is $@, but it is never read. | issue7506.js:15:5:15:10 | p1: '' | written |
+| undefined.js:1:1:1:45 | class C ... }\\n} | Component state property 'notWritten' is $@, but it is never written. | undefined.js:8:9:8:29 | this.st ... Written | read |
+| undefined.js:1:1:1:45 | class C ... }\\n} | Component state property 'notWrittenButReadInChain' is $@, but it is never written. | undefined.js:9:9:9:43 | this.st ... InChain | read |
+| undefined.js:32:1:32:45 | class C ... }\\n} | Component state property 'notWrittenThrougExternalPropertyAccess' is $@, but it is never written. | undefined.js:35:9:35:57 | this.st ... yAccess | read |
+| undefined.js:61:19:61:30 | { // $ ... ;\\n }\\n} | Component state property 'notWrittenInKnownInitializerObject' is $@, but it is never written. | undefined.js:64:9:64:53 | this.st ... rObject | read |
+| unused.js:1:1:1:45 | class C ... }\\n} | Component state property 'notRead' is $@, but it is never read. | unused.js:6:9:6:26 | this.state.notRead | written |
+| unused.js:27:1:27:45 | class C ... }\\n} | Component state property 'notReadThrougExternaPropertyAccess' is $@, but it is never read. | unused.js:30:9:30:53 | this.st ... yAccess | written |
diff --git a/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/UnusedOrUndefinedStateProperty.qlref b/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/UnusedOrUndefinedStateProperty.qlref
index 2b285a04cd8f..a767c2444b8d 100644
--- a/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/UnusedOrUndefinedStateProperty.qlref
+++ b/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/UnusedOrUndefinedStateProperty.qlref
@@ -1 +1,2 @@
-React/UnusedOrUndefinedStateProperty.ql
\ No newline at end of file
+query: React/UnusedOrUndefinedStateProperty.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/issue7506.js b/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/issue7506.js
index f5acdc8d99ab..07932d220d65 100644
--- a/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/issue7506.js
+++ b/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/issue7506.js
@@ -9,10 +9,10 @@ class C1 extends React.Component {
}
}
-class C2 extends React.Component {
+class C2 extends React.Component { // $ Alert
state = {
- p1: ''
+ p1: '' // $ RelatedLocation
}
static getDerivedStateFromProps_unmodeled(props, state) {
diff --git a/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/undefined.js b/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/undefined.js
index 6db5702e2fcf..165ab793ac71 100644
--- a/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/undefined.js
+++ b/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/undefined.js
@@ -1,14 +1,14 @@
-class C1 extends React.Component {
+class C1 extends React.Component { // $ Alert
constructor() {
this.state.writtenDirectly = 42;
this.setState({
writtenInSetState: 42
});
- this.state.writtenInOtherMethod; // OK
- this.state.notWritten; // NOT OK
- this.state.notWrittenButReadInChain; // NOT OK
- this.state.writtenDirectly; // OK
- this.state.writtenInSetState; // OK
+ this.state.writtenInOtherMethod;
+ this.state.notWritten; // $ RelatedLocation
+ this.state.notWrittenButReadInChain; // $ RelatedLocation
+ this.state.writtenDirectly;
+ this.state.writtenInSetState;
}
@@ -23,16 +23,16 @@ class C2 extends React.Component {
s.writtenWhenEscaped = 42;
}
f(this.state);
- this.state.writtenWhenEscaped; // OK
- this.state.notWrittenWhenEscaped; // NOT OK, but ignored to avoid FP above
+ this.state.writtenWhenEscaped;
+ this.state.notWrittenWhenEscaped; // OK - ignored to avoid FP above
}
}
-class C3 extends React.Component {
+class C3 extends React.Component { // $ Alert
constructor() {
- this.state.writtenThrougExternalPropertyAccess; // OK
- this.state.notWrittenThrougExternalPropertyAccess; // NOT OK
+ this.state.writtenThrougExternalPropertyAccess;
+ this.state.notWrittenThrougExternalPropertyAccess; // $ RelatedLocation
}
}
@@ -44,24 +44,24 @@ class C4 extends React.Component {
return { writtenInUnknownInitializerObject: 42 };
}
this.state = f();
- this.state.writtenInUnknownInitializerObject; // OK
- this.state.notWrittenInUnknownInitializerObject; // NOT OK, but ignored to avoid FP above
+ this.state.writtenInUnknownInitializerObject;
+ this.state.notWrittenInUnknownInitializerObject; // OK - ignored to avoid FP above
}
}
class C5 extends React.Component {
constructor(x) {
this.state = x;
- this.state.writtenInUnknownInitializerObject; // OK
- this.state.notWrittenInUnknownInitializerObject; // NOT OK, but ignored to avoid FP above
+ this.state.writtenInUnknownInitializerObject;
+ this.state.notWrittenInUnknownInitializerObject; // OK - ignored to avoid FP above
}
}
new C5({writtenInUnknownInitializerObject: 42});
-React.createClass({
+React.createClass({ // $ Alert
render: function() {
- this.state.writtenInKnownInitializerObject; // OK
- this.state.notWrittenInKnownInitializerObject; // NOT OK
+ this.state.writtenInKnownInitializerObject;
+ this.state.notWrittenInKnownInitializerObject; // $ RelatedLocation
return
;
},
getInitialState: function() {
@@ -74,8 +74,8 @@ React.createClass({
function f(){
return { writtenInUnknownInitializerObject: 42 };
}
- this.state.writtenInUnknownInitializerObject; // OK
- this.state.notWrittenInUnknownInitializerObject; // NOT OK, but ignored to avoid FP above
+ this.state.writtenInUnknownInitializerObject;
+ this.state.notWrittenInUnknownInitializerObject; // OK - ignored to avoid FP above
return
;
},
getInitialState: function() {
@@ -86,8 +86,8 @@ React.createClass({
class C6 extends React.Component {
constructor(x) {
Object.assign(this.state, {writtenInObjectAssign: 42});
- this.state.writtenInObjectAssign; // OK
- this.state.notWrittenInObjectAssign; // NOT OK, but ignored to avoid FP above
+ this.state.writtenInObjectAssign;
+ this.state.notWrittenInObjectAssign; // OK - ignored to avoid FP above
}
}
@@ -96,8 +96,8 @@ class C6 extends React.Component {
function f(){
return { writtenInSetState: 42 };
}
- this.state.writtenSetState; // OK
- this.state.notWrittenSetState; // NOT OK, but ignored to avoid FP above
+ this.state.writtenSetState;
+ this.state.notWrittenSetState; // OK - ignored to avoid FP above
this.setState(f());
}
}
@@ -107,7 +107,7 @@ class C7 extends React.Component {
function f(){
return { writtenInSetState: 42 };
}
- this.state.writtenInSetState; // OK
+ this.state.writtenInSetState;
this.setState(f);
}
}
@@ -120,8 +120,8 @@ class C8 extends React.Component {
function g() {
return { writtenInSetState: 42 }
}
- this.state.writtenInSetState; // OK
- this.state.notInWrittenSetState; // NOT OK, but ignored to avoid FP above
+ this.state.writtenInSetState;
+ this.state.notInWrittenSetState; // OK - ignored to avoid FP above
this.setState(f());
}
}
@@ -131,8 +131,8 @@ class C9 extends React.Component {
function f() { return "readThroughUnknownDynamicPropertyAccess"; }
this.state[f()] = 42;
- this.state.writtenThroughUnknownDynamicPropertyAccess; // OK
- this.state.notWrittenThroughUnknownDynamicPropertyAccess; // NOT OK, but ignored to avoid FP above
+ this.state.writtenThroughUnknownDynamicPropertyAccess;
+ this.state.notWrittenThroughUnknownDynamicPropertyAccess; // OK - ignored to avoid FP above
}
}
@@ -141,15 +141,15 @@ class C10 extends React.Component {
constructor() {
var x = { writtenThroughUnknownSpreadAccess: 42 };
this.state = { ...x };
- this.state.writtenThroughUnknownSpreadAccess; // OK
- this.state.notWrittenThroughUnknownSpreadAccess// NOT OK, but ignored to avoid FP above
+ this.state.writtenThroughUnknownSpreadAccess;
+ this.state.notWrittenThroughUnknownSpreadAccess// OK - ignored to avoid FP above
}
}
React.createClass({
render: function() {
- this.state.writtenThroughMixin; // OK
- this.state.notWrittenThroughMixin; // NOT OK, but ignored to avoid FP above
+ this.state.writtenThroughMixin;
+ this.state.notWrittenThroughMixin; // OK - ignored to avoid FP above
return
;
},
@@ -163,6 +163,6 @@ class C11 extends React.Component {
}
otherMethod() {
- this.state.writeIn_getDerivedStateFromProps; // OK
+ this.state.writeIn_getDerivedStateFromProps;
}
}
diff --git a/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/unused.js b/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/unused.js
index d71aa7136da9..60673a23b620 100644
--- a/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/unused.js
+++ b/javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/unused.js
@@ -1,9 +1,9 @@
-class C1 extends React.Component {
+class C1 extends React.Component { // $ Alert
constructor() {
- this.state.readDirectly = 42; // OK
- this.state.readInChain = {}; // OK
- this.state.readInOtherMethod = {}; // OK
- this.state.notRead = 42; // NOT OK
+ this.state.readDirectly = 42;
+ this.state.readInChain = {};
+ this.state.readInOtherMethod = {};
+ this.state.notRead = 42; // $ RelatedLocation
this.state.readDirectly;
this.state.readInChain.foo;
}
@@ -18,16 +18,16 @@ function f(s){
}
class C2 extends React.Component {
constructor() {
- this.state.readWhenEscaped = 42; // NOT OK
+ this.state.readWhenEscaped = 42;
f(this.state);
}
}
-class C3 extends React.Component {
+class C3 extends React.Component { // $ Alert
constructor() {
- this.state.readThrougExternaPropertyAccess = 42; // OK
- this.state.notReadThrougExternaPropertyAccess = 42; // NOT OK
+ this.state.readThrougExternaPropertyAccess = 42;
+ this.state.notReadThrougExternaPropertyAccess = 42; // $ RelatedLocation
}
}
@@ -36,8 +36,8 @@ new C3().state.readThrougExternaPropertyAccess;
class C4 extends React.Component {
constructor() {
function f() { return "readThroughUnknownDynamicPropertyAccess"; }
- this.state.readThroughUnknownDynamicPropertyAccess = 42; // OK
- this.state.notReadThroughUnknownDynamicPropertyAccess = 42; // NOT OK, but ignored to avoid FP above
+ this.state.readThroughUnknownDynamicPropertyAccess = 42;
+ this.state.notReadThroughUnknownDynamicPropertyAccess = 42; // $ OK - ignored to avoid FP above
this.state[f()];
}
@@ -46,15 +46,15 @@ class C4 extends React.Component {
class C5 extends React.Component {
constructor() {
- this.state.readThroughSpreadOperator = 42; // OK
+ this.state.readThroughSpreadOperator = 42;
({...this.state});
}
}
React.createClass({
render: function() {
- this.state.readThroughMixin = 42; // OK
- this.state.notReadThroughMixin = 42; // NOT OK, but ignored to avoid FP above
+ this.state.readThroughMixin = 42;
+ this.state.notReadThroughMixin = 42; // $ OK - ignored to avoid FP above
return
;
},
@@ -68,7 +68,7 @@ class C6 extends React.Component {
}
constructor() {
- this.state.readIn_getDerivedStateFromProps = 42; // OK
+ this.state.readIn_getDerivedStateFromProps = 42;
}
}
diff --git a/javascript/ql/test/query-tests/RegExp/BackrefBeforeGroup/BackrefBeforeGroup.qlref b/javascript/ql/test/query-tests/RegExp/BackrefBeforeGroup/BackrefBeforeGroup.qlref
index 3c5f29d2f914..0096b5fd9e9c 100644
--- a/javascript/ql/test/query-tests/RegExp/BackrefBeforeGroup/BackrefBeforeGroup.qlref
+++ b/javascript/ql/test/query-tests/RegExp/BackrefBeforeGroup/BackrefBeforeGroup.qlref
@@ -1 +1,2 @@
-RegExp/BackrefBeforeGroup.ql
\ No newline at end of file
+query: RegExp/BackrefBeforeGroup.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/javascript/ql/test/query-tests/RegExp/BackrefBeforeGroup/tst.js b/javascript/ql/test/query-tests/RegExp/BackrefBeforeGroup/tst.js
index 2ac332dfb38d..83fd7871d4ed 100644
--- a/javascript/ql/test/query-tests/RegExp/BackrefBeforeGroup/tst.js
+++ b/javascript/ql/test/query-tests/RegExp/BackrefBeforeGroup/tst.js
@@ -1,9 +1,9 @@
-/\1(abc)/; // NOT OK
-/(a\1c)/; // NOT OK
-/(ab)\2(c)/; // NOT OK
-/(?:ab)\1(c)/; // NOT OK
+/\1(abc)/; // $ Alert
+/(a\1c)/; // $ Alert
+/(ab)\2(c)/; // $ Alert
+/(?:ab)\1(c)/; // $ Alert
/(abc)\1/;
/