Skip to content

Commit 18762db

Browse files
committed
Ruby: factor out isProcCreationCall
1 parent 8d2dba1 commit 18762db

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,16 +1333,20 @@ predicate lambdaCreation(Node creation, LambdaCallKind kind, DataFlowCallable c)
13331333
creation.asExpr() =
13341334
any(CfgNodes::ExprNodes::MethodCallCfgNode mc |
13351335
c.asCallable() = mc.getBlock().getExpr() and
1336-
(
1337-
mc.getExpr().getMethodName() = ["lambda", "proc"]
1338-
or
1339-
mc.getExpr().getMethodName() = "new" and
1340-
mc.getReceiver().getExpr().(ConstantReadAccess).getAQualifiedName() = "Proc"
1341-
)
1336+
isProcCreationCall(mc.getExpr())
13421337
)
13431338
)
13441339
}
13451340

1341+
/** Holds if `call` is a call to `lambda`, `proc`, or `Proc.new` */
1342+
pragma[nomagic]
1343+
private predicate isProcCreationCall(MethodCall call) {
1344+
call.getMethodName() = ["proc", "lambda"]
1345+
or
1346+
call.getMethodName() = "new" and
1347+
call.getReceiver().(ConstantReadAccess).getAQualifiedName() = "Proc"
1348+
}
1349+
13461350
/**
13471351
* Holds if `call` is a from-source lambda call of kind `kind` where `receiver`
13481352
* is the lambda expression.

0 commit comments

Comments
 (0)