Skip to content

Commit 74155a0

Browse files
committed
ruby: start adding comments
I apuse here, because the code may be simplified
1 parent 51a2d8c commit 74155a0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@ import codeql.ruby.Concepts
1515
import codeql.ruby.frameworks.ActiveRecord
1616
private import codeql.ruby.TaintTracking
1717

18-
string loopMethodName() {
18+
/** Gets the name of a built-in method that involves a loop operation. */
19+
string getALoopMethodName() {
1920
result in [
2021
"each", "reverse_each", "map", "map!", "foreach", "flat_map", "in_batches", "one?", "all?",
2122
"collect", "collect!", "select", "select!", "reject", "reject!"
2223
]
2324
}
2425

26+
/** A call to a loop operation. */
2527
class LoopingCall extends DataFlow::CallNode {
2628
DataFlow::CallableNode loopBlock;
2729

2830
LoopingCall() {
29-
this.getMethodName() = loopMethodName() and loopBlock = this.getBlock().asCallable()
31+
this.getMethodName() = getALoopMethodName() and loopBlock = this.getBlock().asCallable()
3032
}
3133

3234
DataFlow::CallableNode getLoopBlock() { result = loopBlock }

0 commit comments

Comments
 (0)