Skip to content

Commit 7bec7ba

Browse files
committed
Ruby: exclude methods with calls to 'super'
when the call has no arguments
1 parent 9188fde commit 7bec7ba

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ruby/ql/src/queries/variables/UnusedParameter.ql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,9 @@ class RelevantParameterVariable extends LocalVariable {
2525

2626
from RelevantParameterVariable v
2727
where
28-
not exists(Ssa::WriteDefinition def | def.getWriteAccess().getAstNode() = v.getDefiningAccess())
28+
not exists(Ssa::WriteDefinition def | def.getWriteAccess().getAstNode() = v.getDefiningAccess()) and
29+
not exists(SuperCall s | s.getEnclosingCallable().getAParameter().getAVariable() = v |
30+
// a call to 'super' without any arguments will pass on the parameter.
31+
not exists(s.getAnArgument())
32+
)
2933
select v, "The parameter '" + v.getName() + "' is never used."

0 commit comments

Comments
 (0)