mirror of
https://github.com/github/codeql.git
synced 2026-04-29 10:45:15 +02:00
JS: Update OK-style comments to $-style
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
// BAD
|
||||
function countOccurrences(xs, p) {
|
||||
function countOccurrences(xs, p) { // $ Alert
|
||||
var count = 0;
|
||||
for (let x of xs)
|
||||
if (p())
|
||||
@@ -7,7 +6,7 @@ function countOccurrences(xs, p) {
|
||||
return count;
|
||||
}
|
||||
|
||||
// OK
|
||||
|
||||
function countOccurrences(xs, p) {
|
||||
var count = 0;
|
||||
for (let x of xs)
|
||||
@@ -16,7 +15,7 @@ function countOccurrences(xs, p) {
|
||||
return count;
|
||||
}
|
||||
|
||||
// OK
|
||||
|
||||
function countOccurrences(xs, p) {
|
||||
var count = 0;
|
||||
for (let unused of xs)
|
||||
@@ -25,14 +24,14 @@ function countOccurrences(xs, p) {
|
||||
return count;
|
||||
}
|
||||
|
||||
// OK
|
||||
|
||||
function isEmpty(o) {
|
||||
for (var x in o)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// OK
|
||||
|
||||
function getNumElt(o) {
|
||||
var count = 0;
|
||||
for (var x of o)
|
||||
@@ -40,7 +39,7 @@ function getNumElt(o) {
|
||||
return count;
|
||||
}
|
||||
|
||||
// OK
|
||||
|
||||
function getNumElt(o) {
|
||||
var count = 0;
|
||||
for (var x of o) {
|
||||
@@ -49,7 +48,7 @@ function getNumElt(o) {
|
||||
return count;
|
||||
}
|
||||
|
||||
// OK
|
||||
|
||||
function getNumElt(o) {
|
||||
var count = 0;
|
||||
for (var x of o)
|
||||
@@ -57,7 +56,7 @@ function getNumElt(o) {
|
||||
return count;
|
||||
}
|
||||
|
||||
// OK
|
||||
|
||||
function getNumElt(o) {
|
||||
var count = 0;
|
||||
for (var x of o)
|
||||
@@ -65,7 +64,7 @@ function getNumElt(o) {
|
||||
return count;
|
||||
}
|
||||
|
||||
// OK
|
||||
|
||||
function getNumElt(o) {
|
||||
var count = 0;
|
||||
for (var x of o) {
|
||||
@@ -75,7 +74,7 @@ function getNumElt(o) {
|
||||
return count;
|
||||
}
|
||||
|
||||
// OK
|
||||
|
||||
function f(o) {
|
||||
for (var p in o)
|
||||
(function() {
|
||||
@@ -83,20 +82,20 @@ function f(o) {
|
||||
})();
|
||||
}
|
||||
|
||||
// OK
|
||||
|
||||
function lastProp(o) {
|
||||
var key;
|
||||
for (key in obj);
|
||||
return key;
|
||||
}
|
||||
|
||||
// OK
|
||||
|
||||
function g() {
|
||||
for (var unused in {"toString": null})
|
||||
hasDontEnumBug = false;
|
||||
}
|
||||
|
||||
// OK
|
||||
|
||||
function is_empty(obj) {
|
||||
var empty = true;
|
||||
for (var key in obj) {
|
||||
@@ -106,7 +105,7 @@ function is_empty(obj) {
|
||||
return empty;
|
||||
}
|
||||
|
||||
// OK
|
||||
|
||||
function f(objs) {
|
||||
var non_empties = 0;
|
||||
for (var obj in objs) {
|
||||
@@ -118,7 +117,7 @@ function f(objs) {
|
||||
return non_empties;
|
||||
}
|
||||
|
||||
// OK: dead loops are not flagged
|
||||
// OK - dead loops are not flagged
|
||||
function countOccurrencesDead(xs, p) {
|
||||
return;
|
||||
var count = 0;
|
||||
@@ -134,19 +133,17 @@ function countOccurrencesDead(xs, p) {
|
||||
}
|
||||
});
|
||||
|
||||
// NOT OK
|
||||
for (const [key, value] of array) {}
|
||||
for (const [key, value] of array) {} // $ Alert
|
||||
|
||||
// OK: for array-destructurings we only flag the last element
|
||||
// OK - for array-destructurings we only flag the last element
|
||||
for (const [key, value] of array) {
|
||||
console.log(value)
|
||||
}
|
||||
|
||||
// OK: for array-destructurings we only flag the last element
|
||||
// OK - for array-destructurings we only flag the last element
|
||||
for (const [key, key2, key3, value] of array) {
|
||||
console.log(value)
|
||||
}
|
||||
|
||||
// NOT OK
|
||||
for (const [key, key2, key3, value] of array) {}
|
||||
for (const [key, key2, key3, value] of array) {} // $ Alert
|
||||
for (let i of [1, 2]) {}
|
||||
Reference in New Issue
Block a user