Skip to content

Files

Latest commit

 

History

History
52 lines (37 loc) · 1 KB

Lint-UnusedBlockArgument.md

File metadata and controls

52 lines (37 loc) · 1 KB

Pattern: Unused block argument

Issue: -

Description

Use _ to prefix unused block parameters and local variables. It's also acceptable to use just _ (although it's a bit less descriptive). This convention is recognized by the Ruby interpreter and tools like RuboCop and will suppress their unused variable warnings.

Examples

# bad

do_something do |used, unused|
  puts used
end

do_something do |bar|
  puts :foo
end

define_method(:foo) do |bar|
  puts :baz
end
#good

do_something do |used, _unused|
  puts used
end

do_something do
  puts :foo
end

define_method(:foo) do |_bar|
  puts :baz
end

Default configuration

Attribute Value
IgnoreEmptyBlocks true
AllowUnusedKeywordArguments false

Further Reading