Skip to content

Commit f15cbb9

Browse files
committed
Ruby: Simplify viableSourceCallableNonInit
1 parent a0018c9 commit f15cbb9

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,14 @@ predicate isUserDefinedNew(SingletonMethod new) {
309309
}
310310

311311
private Callable viableSourceCallableNonInit(RelevantCall call) {
312-
result = getTarget(call) and
313-
not result = blockCall(call) // handled by `lambdaCreation`/`lambdaCall`
312+
result = getTargetInstance(call, _)
313+
or
314+
result = getTargetSingleton(call, _)
315+
or
316+
exists(Module cls, string method |
317+
superCall(call, cls, method) and
318+
result = lookupMethod(cls.getAnImmediateAncestor(), method)
319+
)
314320
}
315321

316322
private Callable viableSourceCallableInit(RelevantCall call) { result = getInitializeTarget(call) }
@@ -400,14 +406,7 @@ private module Cached {
400406

401407
cached
402408
CfgScope getTarget(RelevantCall call) {
403-
result = getTargetInstance(call, _)
404-
or
405-
result = getTargetSingleton(call, _)
406-
or
407-
exists(Module cls, string method |
408-
superCall(call, cls, method) and
409-
result = lookupMethod(cls.getAnImmediateAncestor(), method)
410-
)
409+
result = viableSourceCallableNonInit(call)
411410
or
412411
result = blockCall(call)
413412
}

0 commit comments

Comments
 (0)