mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
JS: add testss for js/trivial-conditional
This commit is contained in:
@@ -25,6 +25,8 @@
|
||||
| UselessConditional.js:129:6:129:24 | constantUndefined() | This call to constantUndefined always evaluates to false. |
|
||||
| UselessConditional.js:135:6:135:32 | constan ... ined1() | This call to constantFalseOrUndefined1 always evaluates to false. |
|
||||
| UselessConditional.js:139:6:139:32 | constan ... ined2() | This call to constantFalseOrUndefined2 always evaluates to false. |
|
||||
| UselessConditional.js:148:6:148:8 | p() | This call to p always evaluates to true. |
|
||||
| UselessConditional.js:163:5:163:17 | findOrThrow() | This call to findOrThrow always evaluates to true. |
|
||||
| UselessConditionalGood.js:58:12:58:13 | x2 | This use of variable 'x2' always evaluates to false. |
|
||||
| UselessConditionalGood.js:69:12:69:13 | xy | This use of variable 'xy' always evaluates to false. |
|
||||
| UselessConditionalGood.js:85:12:85:13 | xy | This use of variable 'xy' always evaluates to false. |
|
||||
|
||||
@@ -140,4 +140,41 @@ async function awaitFlow(){
|
||||
return;
|
||||
|
||||
});
|
||||
|
||||
(function () {
|
||||
function p() {
|
||||
return {};
|
||||
}
|
||||
if (p()) { // NOT OK
|
||||
}
|
||||
var v = p();
|
||||
if (v) { // NOT OK
|
||||
}
|
||||
if (v) { // NOT OK, but not detected due to SSA limitations
|
||||
}
|
||||
});
|
||||
|
||||
(function() {
|
||||
function findOrThrow() {
|
||||
var e = find();
|
||||
if (e) return e;
|
||||
throw new Error();
|
||||
}
|
||||
if(findOrThrow()){ // NOT OK
|
||||
}
|
||||
var v = findOrThrow();
|
||||
if (v) { // NOT OK
|
||||
}
|
||||
if (v) { // NOT OK, but not detected due to SSA limitations
|
||||
}
|
||||
});
|
||||
|
||||
(function () {
|
||||
function f(){ return { v: unkown };}
|
||||
f();
|
||||
var { v } = f();
|
||||
if (v) { // OK
|
||||
}
|
||||
});
|
||||
|
||||
// semmle-extractor-options: --experimental
|
||||
|
||||
Reference in New Issue
Block a user