mirror of
https://github.com/github/codeql.git
synced 2025-12-17 17:23:36 +01:00
76 lines
1.3 KiB
JavaScript
76 lines
1.3 KiB
JavaScript
async function getThing() {
|
|
return something();
|
|
}
|
|
|
|
function useThing() {
|
|
let thing = getThing();
|
|
|
|
if (thing === undefined) {} // $ Alert
|
|
|
|
if (thing == null) {} // $ Alert
|
|
|
|
something(thing ? 1 : 2); // $ Alert
|
|
|
|
for (let x in thing) { // $ Alert
|
|
something(x);
|
|
}
|
|
|
|
let obj = something();
|
|
something(obj[thing]); // $ Alert
|
|
obj[thing] = 5; // $ Alert
|
|
|
|
something(thing + "bar"); // $ Alert
|
|
|
|
if (something()) {
|
|
if (thing) { // $ Alert
|
|
something(3);
|
|
}
|
|
}
|
|
}
|
|
|
|
async function useThingCorrectly() {
|
|
let thing = await getThing();
|
|
|
|
if (thing === undefined) {}
|
|
|
|
if (thing == null) {}
|
|
|
|
return thing + "bar";
|
|
}
|
|
|
|
async function useThingCorrectly2() {
|
|
let thing = getThing();
|
|
|
|
if (await thing === undefined) {}
|
|
|
|
if (await thing == null) {}
|
|
|
|
return thing + "bar"; // $ Alert
|
|
}
|
|
|
|
function getThingSync() {
|
|
return something();
|
|
}
|
|
|
|
function useThingPossiblySync(b) {
|
|
let thing = b ? getThing() : getThingSync();
|
|
|
|
if (thing === undefined) {}
|
|
|
|
if (thing == null) {}
|
|
|
|
return thing + "bar"; // $ MISSING: Alert
|
|
}
|
|
|
|
function useThingInVoid() {
|
|
void getThing();
|
|
}
|
|
|
|
function useThing() {
|
|
if (random()) {
|
|
return getThing() ?? null; // $ Alert
|
|
} else {
|
|
return getThing?.() ?? null;
|
|
}
|
|
}
|