Skip to content

Commit

Permalink
JS: Update line expectation comments
Browse files Browse the repository at this point in the history
  • Loading branch information
asgerf committed Feb 7, 2025
1 parent 5ff82b7 commit 3a86b71
Show file tree
Hide file tree
Showing 325 changed files with 1,252 additions and 1,252 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ angular.module('app').directive('addMouseover', function($compile) {

attrs.$set('addMouseover', null); // To stop infinite compile loop
element.append(newEl);
$compile(element)(scope); // Double compilation
$compile(element)(scope); // $ TODO-SPURIOUS: Alert - Double compilation
}
}
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function(){
function f(){}
f.$inject = ['dup5', 'dup5']; // $ Alert
function f(){} // $ TODO-SPURIOUS: Alert
f.$inject = ['dup5', 'dup5']; // $ TODO-MISSING: Alert
angular.module('myModule', [])
.run(['dup1a', 'dup1a', function(dup1a, dup1a){}]) // OK - flagged by js/duplicate-parameter-name
.run(['dup2a', 'dup2a', function(dup2a, dup2b){}]) // $ Alert
Expand All @@ -12,7 +12,7 @@
.run(['notDup8a', 'notDup8b', function(notDup8a, notDup8b){}])
.run(['notDup9a', 'notDup9b', function(notDup9c, notDup9d){}])
.run(['dup10a', 'dup10a', 'dup10a', function(dup10a, dup10a, dup10a){}]) // OK - flagged by js/duplicate-parameter-name
.run(['dup11a', 'dup11a', function(dup11a, dup11b){ // $ Alert - alert formatting for multi-line function
.run(['dup11a', 'dup11a', function(dup11a, dup11b){ // $ TODO-MISSING: Alert - alert formatting for multi-line function
}])
;
})();
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

angular.module('app9').controller('controller9', ['name', function inline9(name){}]);

function $Injected10(name){ // $ Alert - alert formatting for multi-line function
function $Injected10(name){ // $ TODO-MISSING: Alert - alert formatting for multi-line function
}
$Injected10.$inject = ['name'];
angular.module('app10').controller('controller10', ['name', $Injected10]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
.run(f2)
.run(["used2", "unused9", function(used2) {}]) // $ Alert
.run(["unused10", "unused11", function() {}]) // $ Alert
.run(["used2", "unused12", function(used2) { // $ Alert - alert formatting for multi-line function
.run(["used2", "unused12", function(used2) { // $ TODO-MISSING: Alert - alert formatting for multi-line function
}])
;
})();
Expand Down
6 changes: 3 additions & 3 deletions javascript/ql/test/query-tests/AngularJS/UseNgSrc/tst.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
</head>
<body>
<!-- BAD -->
<a href="{{help_url}}">Help</a>
<a href="{{help_url}}">Help</a> // $ TODO-SPURIOUS: Alert
<picture>
<source media="(min-width: 650px)" srcset="#/resources/pics-large/{{item._id}}">
<img src="#/resources/pics-default/{{item._id}}">
<source media="(min-width: 650px)" srcset="#/resources/pics-large/{{item._id}}"> // $ TODO-SPURIOUS: Alert
<img src="#/resources/pics-default/{{item._id}}"> // $ TODO-SPURIOUS: Alert
</picture>
<!-- GOOD -->
<a ng-href="{{help_url}}">Help</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div x-ng-bind="I am here to make this seem like an AngularJS template">
<!-- BAD -->
<a href="{{help_url}}">Help</a>
<a href="{{help_url}}">Help</a> // $ TODO-SPURIOUS: Alert
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<body ng-app>
<!-- BAD -->
<a href="{{help_url}}">Help</a>
<a href="{{help_url}}">Help</a> // $ TODO-SPURIOUS: Alert
</body>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<html>
<body>
<ul>
<li id="first">First element
<li id="first">First element // $ TODO-SPURIOUS: Alert[js/duplicate-html-id]
<li id="first">Second element
</ul>
</body>
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<li id="second">Second element</li>
<li id="{{templated-id}}">Templated id</li> <!-- ignored -->
<li id="{{templated-id}}">Templated id</li> <!-- ignored -->
<li id="invalid id">Invalid id</li> <!-- reported by another query -->
<li id="invalid id">Invalid id</li> <!-- reported by another query -->
<li id="invalid id">Invalid id</li> <!-- reported by another query --> // $ TODO-SPURIOUS: Alert[js/malformed-html-id]
<li id="invalid id">Invalid id</li> <!-- reported by another query --> // $ TODO-SPURIOUS: Alert[js/malformed-html-id]
<li class="duplicate-class">duplicate-class</li>
<li class="duplicate-class">duplicate-class</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ul>
<li id="first">First element
<li id="first">First element // $ TODO-SPURIOUS: Alert[js/duplicate-html-id]
<li id="first">Second element
</ul>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<a href="http://semmle.com" href="https://semmle.com">Semmle</a>
<a href="http://semmle.com" href="https://semmle.com">Semmle</a> // $ TODO-SPURIOUS: Alert[js/conflicting-html-attribute]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<a href="https://semmle.com" href="https://semmle.com">Semmle</a>
<a href="https://semmle.com" href="https://semmle.com">Semmle</a> // $ TODO-SPURIOUS: Alert[js/duplicate-html-attribute]

<td {% foo %} {% foo %}></td>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<div id="heading important">An important heading</div>
<div id="heading important">An important heading</div> // $ TODO-SPURIOUS: Alert[js/malformed-html-id]
14 changes: 7 additions & 7 deletions javascript/ql/test/query-tests/DOM/HTML/tst.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
var div1 = <div id="theDiff"></div>;
var div2 = <div id="theDiff"></div>;

<a href="http://semmle.com" href="https://semmle.com">Semmle</a>; // $ Alert
<a href="http://semmle.com" href="https://semmle.com">Semmle</a>; // $ Alert TODO-MISSING: Alert[js/duplicate-html-attribute] Alert[js/malformed-html-id] Alert[js/duplicate-html-id]

<a href="https://semmle.com" href="https://semmle.com">Semmle</a>; // $ Alert
<a href="https://semmle.com" href="https://semmle.com">Semmle</a>; // $ Alert TODO-MISSING: Alert[js/malformed-html-id] Alert[js/duplicate-html-id] Alert[js/conflicting-html-attribute]

<div id=""></div>; // $ Alert
<div id="a b"></div>;
<div id=""></div>; // $ Alert TODO-MISSING: Alert[js/duplicate-html-attribute] Alert[js/duplicate-html-id] Alert[js/conflicting-html-attribute]
<div id="a b"></div>; // $ TODO-SPURIOUS: Alert[js/malformed-html-id]

<a href="http://semmle.com" href={someValue()}>Semmle</a>; // $ Alert
<a href="http://semmle.com" href={someValue()}>Semmle</a>; // $ Alert TODO-MISSING: Alert[js/duplicate-html-attribute] Alert[js/malformed-html-id] Alert[js/duplicate-html-id]


<div id={someOtherValue()}></div>;

var div3 = <div><div id="theDiff"></div><div id="theDiff"></div></div>; // $ Alert
var div3 = <div><div id="theDiff"></div><div id="theDiff"></div></div>; // $ Alert TODO-MISSING: Alert[js/duplicate-html-attribute] Alert[js/malformed-html-id] Alert[js/conflicting-html-attribute]

var div4 = <div id="theDiff" id="theDiff"></div>; // $ Alert
var div4 = <div id="theDiff" id="theDiff"></div>; // $ Alert TODO-MISSING: Alert[js/malformed-html-id] Alert[js/duplicate-html-id] Alert[js/conflicting-html-attribute]
10 changes: 5 additions & 5 deletions javascript/ql/test/query-tests/DOM/PseudoEval/tst.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
window.setTimeout(";");
setInterval("update();");
window.setTimeout(";"); // $ TODO-SPURIOUS: Alert
setInterval("update();"); // $ TODO-SPURIOUS: Alert
setInterval(update);
document.write("alert('Hi!');");
window.execScript("debugger;");
document.write("alert('Hi!');"); // $ TODO-SPURIOUS: Alert
window.execScript("debugger;"); // $ TODO-SPURIOUS: Alert

(function(global) {
var document = global.document;
document.write("undefined = 2");
document.write("undefined = 2"); // $ TODO-SPURIOUS: Alert
})(this);
6 changes: 3 additions & 3 deletions javascript/ql/test/query-tests/DOM/TargetBlank/tst.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ <h1>OK, because of constant prefix</h1>
<a data-ng-href="https://example.com/{{X}}" target="_blank">Example</a>

<h1>NOT OK, because of dynamic URL</h1>
<a href="http://example.com{{X}}" target="_blank">Example</a>
<a href="{{target}}" target="_blank">Example</a>
<a href="http://example.com{{X}}" target="_blank">Example</a> // $ TODO-SPURIOUS: Alert
<a href="{{target}}" target="_blank">Example</a> // $ TODO-SPURIOUS: Alert
<a href="{{target}}" target="_blank">
Example
</a>

<h1>NOT OK: mailto is not fine.</h1>
<a target="_blank" href="mailto:{{var:mail}}">mail somone</a>
<a target="_blank" href="mailto:{{var:mail}}">mail somone</a> // $ TODO-SPURIOUS: Alert

<h1>OK: template elements after # or ? are fine.</h1>
<a href="file.extension?#[% row.href %]" target="_blank">Example</a>
Expand Down
4 changes: 2 additions & 2 deletions javascript/ql/test/query-tests/DOM/TargetBlank/tst.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ var o = { rel: "noopener noreferrer "};
<a data-ng-href="https://example.com" target="_blank">Example</a>;

<a href="{{X}}" target="_blank">Example</a>; // $ Alert - because of dynamic URL
<a href="{{X}}" target="_blank" rel="nopoener">Example</a>;
<a data-ng-href="{{X}}" target="_blank">Example</a>;
<a href="{{X}}" target="_blank" rel="nopoener">Example</a>; // $ TODO-SPURIOUS: Alert
<a data-ng-href="{{X}}" target="_blank">Example</a>; // $ TODO-SPURIOUS: Alert

function f() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ function g(x, y) {
}

(function (){
for ([arguments] of o);
for ([arguments = 4] of o);
for ([arguments] of o); // $ TODO-SPURIOUS: Alert
for ([arguments = 4] of o); // $ TODO-SPURIOUS: Alert
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ const s = "hi";

(function (){
const c = null;
for ([ c ] of o);
for ([ c ] of o); // $ TODO-SPURIOUS: Alert
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function f(x) {
if (x > 23) {
function g() {
function g() { // $ TODO-SPURIOUS: Alert
return 42;
}
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
onmessage = function() { console.log("Got a message!"); };

onmissage = function() { console.log("How did that happen?"); };
onmissage = function() { console.log("How did that happen?"); }; // $ TODO-SPURIOUS: Alert
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ function k(data) {
}

function l() {
var x = 23;
var x = 23; // $ TODO-SPURIOUS: Alert
x = 42;
return x;
}

function m() {
var x = 23, y;
var x = 23, y; // $ TODO-SPURIOUS: Alert
x = 42, y = x+14;
return x+y;
}
Expand Down Expand Up @@ -127,7 +127,7 @@ function v() {
}

!function(o) {
var {x} = o;
var {x} = o; // $ TODO-SPURIOUS: Alert
x = 42;
return x;
}
Expand Down Expand Up @@ -157,7 +157,7 @@ function v() {
});

(function() {
let [x] = [0], // OK - but flagged due to destructuring limitations
let [x] = [0], // $ TODO-SPURIOUS: Alert - OK - but flagged due to destructuring limitations
y = 0;
x = 42;
y = 87;
Expand All @@ -167,7 +167,7 @@ function v() {

(function() {
if (something()) {
var nSign = foo;
var nSign = foo; // $ TODO-SPURIOUS: Alert
} else {
console.log(nSign);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ function f(event) {
function g() {
let x = 23; // $ Alert
{
x = 42;
x = 42; // $ TODO-SPURIOUS: Alert
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
};

var o = { set setter(value) { } };
o.setter = 42; // probably OK, but still flagged - it seems fishy
o.setter = 42; // $ TODO-SPURIOUS: Alert - probably OK, but still flagged - it seems fishy
o.setter = 87;

var o = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
/*global: z*/ // also not a proper global declaration
w;
x;
y; // $ Alert
y; // $ TODO-MISSING: Alert
z; // $ Alert
var x, y, z;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function f(x, y = defaultVal(x)) {
function f(x, y = defaultVal(x)) { // $ TODO-SPURIOUS: Alert
function defaultVal(x) {
return x+19;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Top {
topNamespaceFunction();
}
childNamespaceFunction(){
childNamespaceFunction(); // $ Alert - but not flagged since the namespace resolution is ignored
childNamespaceFunction(); // $ TODO-MISSING: Alert - but not flagged since the namespace resolution is ignored
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ function p() {
}

function q() {
var x; // $ Alert
y = 23,
var x; // $ TODO-MISSING: Alert
y = 23, // $ TODO-SPURIOUS: Alert
z = y+19;
}

Expand All @@ -63,7 +63,7 @@ function r() {
}

(function() {
for ([ unresolvable ] of o) {
for ([ unresolvable ] of o) { // $ TODO-SPURIOUS: Alert
unresolvable;
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ function sc_alert(i) {
}

function f(o) {
for({x, ...rest} of o)
for({x, ...rest} of o) // $ TODO-SPURIOUS: Alert
console.log(x in rest);
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var fun1;
function fun1() {
function fun1() { // $ TODO-SPURIOUS: Alert
}

function fun2() {
}
var fun2;
var fun2; // $ TODO-SPURIOUS: Alert

var fun3;
var fun = function fun3() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ function k() {
y = 2; // $ Alert
}

var g;
var g; // $ TODO-SPURIOUS: Alert
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function f(
x,
x, // $ TODO-SPURIOUS: Alert
x, // $ Alert
\u0078 // $ Alert
\u0078 // $ TODO-MISSING: Alert
) { return; }

this.addPropertyListener(prop.name, function(_, _, _, a) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var o = {

setX: function(x) {
this.x = x;
},
}, // $ TODO-SPURIOUS: Alert

getX: function() {
return this.x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AudioService } from './audio'
import { StoreService } from './store';

export const services = [
AudioService,
AudioService, // $ TODO-SPURIOUS: Alert
StoreService
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function K(x, y) {
* @param {*} x the first argument
* @param {*} y the second argument
*/
function K(x, y) {
function K(x, y) { // $ TODO-SPURIOUS: Alert
return y;
}

Expand Down
Loading

0 comments on commit 3a86b71

Please sign in to comment.