Skip to content

unused-block-argument

Rubycleanupno fixdefault: offruby/rubocop

Reports a block parameter that the block never reads. Names that start with _ and empty blocks are left alone. No fix.

A block parameter that is never read is a value that the block was given for nothing, or a mistake in the block. A leading _ says that it is skipped on purpose, as when a hash is walked for its values only.

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

Reported
...
x
end
[1].each { |i| i }
[1].each { |i| 1 }
def b(*)
[1].map { |_v| 1 }
end
...
ruby:
lint:
rules:
unused-block-argument: warn # off (default), warn, error

Enabled by the presets: ruby/rubocop.

Suppress one line with sudsy-disable-next-line unused-block-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/UnusedBlockArgument full