Skip to content

Commit a6b20d7

Browse files
authored
Merge pull request #19259 from hvitved/ruby/fix-bad-join
Ruby: Fix bad join in `DeadStoreOfLocal.ql`
2 parents 1ba06ab + 35f9157 commit a6b20d7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: ruby/ql/src/queries/variables/DeadStoreOfLocal.ql

+7-2
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,20 @@
1111
*/
1212

1313
import codeql.ruby.AST
14+
import codeql.ruby.CFG
1415
import codeql.ruby.dataflow.SSA
1516
import codeql.ruby.ApiGraphs
1617

18+
pragma[nomagic]
19+
private predicate hasErbResultCall(CfgScope scope) {
20+
scope = API::getTopLevelMember("ERB").getInstance().getAMethodCall("result").asExpr().getScope()
21+
}
22+
1723
class RelevantLocalVariableWriteAccess extends LocalVariableWriteAccess {
1824
RelevantLocalVariableWriteAccess() {
1925
not this.getVariable().getName().charAt(0) = "_" and
2026
not this = any(Parameter p).getAVariable().getDefiningAccess() and
21-
not API::getTopLevelMember("ERB").getInstance().getAMethodCall("result").asExpr().getScope() =
22-
this.getCfgScope() and
27+
not hasErbResultCall(this.getCfgScope()) and
2328
not exists(RetryStmt r | r.getCfgScope() = this.getCfgScope()) and
2429
not exists(MethodCall c |
2530
c.getReceiver() instanceof SelfVariableAccess and

0 commit comments

Comments
 (0)