Skip to content

unused-method-argument

Rubycleanupno fixdefault: offruby/rubocop

Reports a method parameter that the method never reads. Names that start with _, empty methods and methods that only raise NotImplementedError are left alone. No fix.

An argument that is never read is either dead (callers pass a value for nothing) or a mistake (the method was meant to use it). Naming it with a leading _ says that it is left out on purpose, as in an override that must keep the signature.

To fix, remove the parameter, or prefix its name with _.

Reported
...
def b(*)
[1].map { |_v| 1 }
end
def c(p)
1
end
def d(&blk)
...
ruby:
lint:
rules:
unused-method-argument: warn # off (default), warn, error

Enabled by the presets: ruby/rubocop.

Suppress one line with sudsy-disable-next-line unused-method-argument in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
rubocop Lint/UnusedMethodArgument full