Skip to content

Commit cee986f

Browse files
committed
skip expressions that are alone in a file for js/useless-expression
1 parent 33f4503 commit cee986f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

javascript/ql/src/Expressions/ExprHasNoEffect.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,7 @@ predicate hasNoEffect(Expr e) {
158158
// exclude block-level flow type annotations. For example: `(name: empty)`.
159159
not e.(ParExpr).getExpression().getLastToken().getNextToken().getValue() = ":" and
160160
// exclude the first statement of a try block
161-
not e = any(TryStmt stmt).getBody().getStmt(0).(ExprStmt).getExpr()
161+
not e = any(TryStmt stmt).getBody().getStmt(0).(ExprStmt).getExpr() and
162+
// exclude expressions that are alone in a file
163+
not e.getParent().(ExprStmt).getParent().(TopLevel).getNumChild() = 1
162164
}

0 commit comments

Comments
 (0)