Skip to content

Commit f140820

Browse files
committed
fix FP related to block-level flow type annotations
1 parent 9193a81 commit f140820

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

change-notes/1.24/analysis-javascript.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
| Clear-text logging of sensitive information (`js/clear-text-logging`) | More results | More results involving `process.env` and indirect calls to logging methods are recognized. |
2424
| Incomplete string escaping or encoding (`js/incomplete-sanitization`) | Fewer false positive results | This query now recognizes additional cases where a single replacement is likely to be intentional. |
2525
| Unbound event handler receiver (`js/unbound-event-handler-receiver`) | Fewer false positive results | This query now recognizes additional ways event handler receivers can be bound. |
26+
| Expression has no effect (`js/useless-expression`) | Fewer false positive results | The query now recognizes block-level flow type annotations. |
2627

2728
## Changes to libraries
2829

javascript/ql/src/Expressions/ExprHasNoEffect.qll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ predicate inVoidContext(Expr e) {
4040
exists(LogicalBinaryExpr logical | e = logical.getRightOperand() and inVoidContext(logical))
4141
}
4242

43-
4443
/**
4544
* Holds if `e` is of the form `x;` or `e.p;` and has a JSDoc comment containing a tag.
4645
* In that case, it is probably meant as a declaration and shouldn't be flagged by this query.
@@ -155,5 +154,7 @@ predicate hasNoEffect(Expr e) {
155154
not exists(FunctionExpr fe, ExprStmt es | fe = e |
156155
fe = es.getExpr() and
157156
not exists(fe.getName())
158-
)
159-
}
157+
) and
158+
// exclude block-level flow type annotations. For example: `(name: empty)`.
159+
not e.(ParExpr).getExpression().getLastToken().getNextToken().getValue() = ":"
160+
}

0 commit comments

Comments
 (0)