JS: sharpen the js/trivial-conditional whitelist

This commit is contained in:
Esben Sparre Andreasen
2019-01-24 14:58:15 +01:00
parent feeb391737
commit ef3b107cc1
4 changed files with 50 additions and 8 deletions

View File

@@ -109,4 +109,35 @@ async function awaitFlow(){
if ((x && {}) || y) {} // NOT OK
});
(function(){
function constantFalse1() {
return false;
}
if (constantFalse1()) // OK
return;
function constantFalse2() {
return false;
}
let constantFalse = unknown? constantFalse1 : constantFalse2;
if (constantFalse2()) // OK
return;
function constantUndefined() {
return undefined;
}
if (constantUndefined()) // NOT OK
return;
function constantFalseOrUndefined1() {
return unknown? false: undefined;
}
if (constantFalseOrUndefined1()) // NOT OK
return;
let constantFalseOrUndefined2 = unknown? constantFalse1 : constantUndefined;
if (constantFalseOrUndefined2()) // NOT OK
return;
});
// semmle-extractor-options: --experimental