Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions ruby/ql/src/queries/variables/DeadStoreOfLocal.ql
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@
*/

import codeql.ruby.AST
import codeql.ruby.CFG
import codeql.ruby.dataflow.SSA
import codeql.ruby.ApiGraphs

pragma[nomagic]
private predicate hasErbResultCall(CfgScope scope) {
scope = API::getTopLevelMember("ERB").getInstance().getAMethodCall("result").asExpr().getScope()
}

class RelevantLocalVariableWriteAccess extends LocalVariableWriteAccess {
RelevantLocalVariableWriteAccess() {
not this.getVariable().getName().charAt(0) = "_" and
not this = any(Parameter p).getAVariable().getDefiningAccess() and
not API::getTopLevelMember("ERB").getInstance().getAMethodCall("result").asExpr().getScope() =
this.getCfgScope() and
not hasErbResultCall(this.getCfgScope()) and
not exists(RetryStmt r | r.getCfgScope() = this.getCfgScope()) and
not exists(MethodCall c |
c.getReceiver() instanceof SelfVariableAccess and
Expand Down
Loading