Skip to content

Commit a3ad6f5

Browse files
committed
Ruby: Weaken scopeNoFirst check
1 parent 1bd504b commit a3ad6f5

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

ruby/ql/consistency-queries/CfgConsistency.ql

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import codeql.ruby.controlflow.internal.ControlFlowGraphImpl::Consistency
1+
import codeql.ruby.controlflow.internal.ControlFlowGraphImpl::Consistency as Consistency
2+
import Consistency
23
import codeql.ruby.AST
34
import codeql.ruby.CFG
45
import codeql.ruby.controlflow.internal.Completion
@@ -19,3 +20,14 @@ query predicate nonPostOrderExpr(Expr e, string cls) {
1920
c instanceof NormalCompletion
2021
)
2122
}
23+
24+
query predicate scopeNoFirst(CfgScope scope) {
25+
Consistency::scopeNoFirst(scope) and
26+
not scope = any(StmtSequence seq | not exists(seq.getAStmt())) and
27+
not scope =
28+
any(Callable c |
29+
not exists(c.getAParameter()) and
30+
not c.(BodyStmt).hasEnsure() and
31+
not exists(c.(BodyStmt).getARescue())
32+
)
33+
}

0 commit comments

Comments
 (0)