File tree 1 file changed +11
-1
lines changed
ruby/ql/src/queries/variables
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 12
12
13
13
import codeql.ruby.AST
14
14
import codeql.ruby.dataflow.SSA
15
+ import codeql.ruby.ApiGraphs
15
16
16
17
class RelevantLocalVariableWriteAccess extends LocalVariableWriteAccess {
17
18
RelevantLocalVariableWriteAccess ( ) {
18
19
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 ( )
20
30
}
21
31
}
22
32
You can’t perform that action at this time.
0 commit comments