Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0b48999

Browse files
committed
refactored the attribute checks based on code-review
1 parent 1bbe1ec commit 0b48999

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

javascript/ql/src/Statements/UseOfReturnlessFunction.ql

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ predicate benignContext(Expr e) {
5050
exists(VoidExpr voidExpr | voidExpr.getOperand() = e)
5151

5252
or
53+
// weeds out calls inside HTML-attributes.
54+
e.getContainer() instanceof CodeInAttribute or
55+
// and JSX-attributes.
56+
e = any(JSXAttribute attr).getValue() or
5357

5458
// It is ok (or to be flagged by another query?) to await a non-async function.
5559
exists(AwaitExpr await | await.getOperand() = e and benignContext(await))
@@ -83,11 +87,6 @@ predicate callBlacklist(DataFlow::CallNode call) {
8387

8488
// anonymous one-shot closure. Those are used in weird ways and we ignore them.
8589
call.asExpr() = any(ImmediatelyInvokedFunctionExpr f).getInvocation() or
86-
87-
// weeds out calls inside html-attributes.
88-
call.asExpr().getParent*() instanceof CodeInAttribute or
89-
// and JSX-attributes.
90-
call.asExpr().getParent*() instanceof JSXAttribute or
9190

9291
// Calls on "this" tend to overloaded. So future overloads might start returning something.
9392
call.asExpr().(MethodCallExpr).getReceiver() instanceof ThisExpr or

0 commit comments

Comments
 (0)