Skip to content

Commit b3eaac0

Browse files
committed
ruby: remove superflous logic
1 parent 58fb592 commit b3eaac0

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

ruby/ql/src/queries/performance/DatabaseQueryInLoop.ql

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,6 @@ predicate happensInLoop(LoopingCall loop, DataFlow::CallNode e) {
3838
loop.getLoopBlock().asCallableAstNode() = e.asExpr().getScope()
3939
}
4040

41-
predicate happensInOuterLoop(LoopingCall outerLoop, DataFlow::CallNode e) {
42-
exists(LoopingCall innerLoop |
43-
happensInLoop(outerLoop, innerLoop) and
44-
happensInLoop(innerLoop, e)
45-
)
46-
}
47-
48-
predicate happensInInnermostLoop(LoopingCall loop, DataFlow::CallNode e) {
49-
happensInLoop(loop, e) and
50-
not happensInOuterLoop(loop, e)
51-
}
52-
5341
// The ActiveRecord instance is used to potentially control the loop
5442
predicate usedInLoopControlGuard(ActiveRecordInstance ar, DataFlow::Node guard) {
5543
TaintTracking::localTaint(ar, guard) and
@@ -73,8 +61,7 @@ where
7361
not isArrayConstant(loop.getReceiver().asExpr(), _) and
7462
// Disregard cases where the looping is influenced by the query result
7563
not usedInLoopControlGuard(call, _) and
76-
// Only report the inner most loop
77-
happensInInnermostLoop(loop, call) and
64+
happensInLoop(loop, call) and
7865
// Only report calls that are likely to be expensive
7966
call instanceof ActiveRecordModelFinderCall and
8067
not call.getMethodName() in ["new", "create"]

0 commit comments

Comments
 (0)