File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
ruby/ql/src/queries/variables Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 1212
1313import codeql.ruby.AST
1414import codeql.ruby.dataflow.SSA
15+ import codeql.ruby.ApiGraphs
1516
1617class RelevantLocalVariableWriteAccess extends LocalVariableWriteAccess {
1718 RelevantLocalVariableWriteAccess ( ) {
1819 not this .getVariable ( ) .getName ( ) .charAt ( 0 ) = "_" and
19- not this = any ( Parameter p ) .getAVariable ( ) .getDefiningAccess ( )
20+ not this = any ( Parameter p ) .getAVariable ( ) .getDefiningAccess ( ) and
21+ not exists ( SuperCall s |
22+ s .getEnclosingCallable ( ) .getAParameter ( ) .getAVariable ( ) .getAnAccess ( ) = this
23+ |
24+ // a call to 'super' without any arguments will pass on the parameter.
25+ // thus, the parameter is used, and the assignment is not useless.
26+ not exists ( s .getAnArgument ( ) )
27+ ) and
28+ not API:: getTopLevelMember ( "ERB" ) .getInstance ( ) .getAMethodCall ( "result" ) .asExpr ( ) .getScope ( ) =
29+ this .getCfgScope ( )
2030 }
2131}
2232
You can’t perform that action at this time.
0 commit comments