mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
JavaScript: Fix false positive on Flow type annotations in ExprHasNoEffect
This commit is contained in:
@@ -174,7 +174,10 @@ predicate hasNoEffect(Expr e) {
|
||||
not exists(fe.getName())
|
||||
) and
|
||||
// exclude block-level flow type annotations. For example: `(name: empty)`.
|
||||
not e.(ParExpr).getExpression().getLastToken().getNextToken().getValue() = ":" and
|
||||
not exists(ParExpr parent |
|
||||
e.getParent() = parent and
|
||||
e.getLastToken().getNextToken().getValue() = ":"
|
||||
) and
|
||||
// exclude the first statement of a try block
|
||||
not e = any(TryStmt stmt).getBody().getStmt(0).(ExprStmt).getExpr() and
|
||||
// exclude expressions that are alone in a file, and file doesn't contain a function.
|
||||
|
||||
@@ -11,6 +11,5 @@
|
||||
| tst.js:49:3:49:49 | new Syn ... o me?") | This expression has no effect. |
|
||||
| tst.js:50:3:50:36 | new Err ... age(e)) | This expression has no effect. |
|
||||
| tst.js:61:2:61:20 | o.trivialNonGetter1 | This expression has no effect. |
|
||||
| tst.js:75:3:75:3 | o | This expression has no effect. |
|
||||
| tst.js:77:24:77:24 | o | This expression has no effect. |
|
||||
| uselessfn.js:1:2:1:26 | functio ... d.");\\n} | This expression has no effect. |
|
||||
|
||||
@@ -72,7 +72,7 @@ function g() {
|
||||
Object.defineProperty(o, "nonTrivialGetter2", unknownGetterDef());
|
||||
o.nonTrivialGetter2;
|
||||
|
||||
(o: empty); // $SPURIOUS:Alert
|
||||
(o: empty);
|
||||
|
||||
testSomeCondition() ? o : // $ Alert
|
||||
doSomethingDangerous();
|
||||
|
||||
Reference in New Issue
Block a user