@@ -32,9 +32,10 @@ predicate benignContext(Expr e) {
3232 inVoidContext ( e ) or
3333
3434 // A return statement is often used to just end the function.
35- exists ( ReturnStmt ret |
36- ret .getExpr ( ) = e
37- )
35+ e = any ( Function f ) .getAReturnedExpr ( )
36+ or
37+ // The call is only in a non-void context because it is in a lambda.
38+ e = any ( ArrowFunctionExpr arrow ) .getBody ( )
3839 or
3940 exists ( ConditionalExpr cond | cond .getABranch ( ) = e and benignContext ( cond ) )
4041 or
@@ -47,12 +48,7 @@ predicate benignContext(Expr e) {
4748 exists ( Expr parent | parent .getUnderlyingValue ( ) = e and benignContext ( parent ) )
4849 or
4950 exists ( VoidExpr voidExpr | voidExpr .getOperand ( ) = e )
50- or
51-
52- // The call is only in a non-void context because it is in a lambda.
53- exists ( ArrowFunctionExpr arrow |
54- arrow .getBody ( ) = e
55- )
51+
5652 or
5753
5854 // It is ok (or to be flagged by another query?) to await a non-async function.
@@ -67,8 +63,11 @@ predicate benignContext(Expr e) {
6763 // Avoid double reporting with js/property-access-on-non-object
6864 exists ( PropAccess ac | ac .getBase ( ) = e )
6965 or
70- // Avoid double-reporting with unused local.
66+ // Avoid double-reporting with js/ unused- local-variable
7167 exists ( VariableDeclarator v | v .getInit ( ) = e and v .getBindingPattern ( ) .getVariable ( ) instanceof UnusedLocal )
68+ or
69+ // Avoid double reporting with js/call-to-non-callable
70+ exists ( InvokeExpr invoke | invoke .getCallee ( ) = e )
7271}
7372
7473from Function f , DataFlow:: CallNode call
0 commit comments