mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Improve inVoidContext to take conditional expressions into account.
This commit is contained in:
committed by
Erik Krogh Kristensen
parent
2f436c800b
commit
47e425a184
@@ -37,6 +37,8 @@ predicate inVoidContext(Expr e) {
|
||||
)
|
||||
or
|
||||
exists(LogicalBinaryExpr logical | e = logical.getRightOperand() and inVoidContext(logical))
|
||||
or
|
||||
exists(ConditionalExpr cond | e = cond.getABranch() | inVoidContext(cond))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,4 +10,5 @@
|
||||
| tst.js:50:3:50:49 | new Syn ... o me?") | This expression has no effect. |
|
||||
| tst.js:51:3:51:36 | new Err ... age(e)) | This expression has no effect. |
|
||||
| tst.js:62:2:62:20 | o.trivialNonGetter1 | This expression has no effect. |
|
||||
| tst.js:78:24:78:24 | o | This expression has no effect. |
|
||||
| uselessfn.js:1:1:1:15 | (functi ... .");\\n}) | This expression has no effect. |
|
||||
|
||||
@@ -73,5 +73,11 @@ function g() {
|
||||
Object.defineProperty(o, "nonTrivialGetter2", unknownGetterDef());
|
||||
o.nonTrivialGetter2; // OK
|
||||
|
||||
(o: empty); // OK.
|
||||
(o: empty); // OK
|
||||
|
||||
testSomeCondition() ? o : // NOT OK
|
||||
doSomethingDangerous();
|
||||
|
||||
consume(testSomeCondition() ? o : // OK
|
||||
doSomethingDangerous());
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user