You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using define_method to define a method, the block arguments given will turn into method arguments on the defined method. So when the Lint/UnusedBlockArgument cop recommends that I “can omit the argument”, it is actually suggesting that I change the arity of a method without changing its callers.
Running RuboCop with the -a flag does the right thing and prefixes the unused argument with an underscore.
Expected behavior
Recommend that I use _ prefix for unused block argument to define_method.
Actual behavior
Recommend that I use delete the “unused” block argument to define_method.
Steps to reproduce the problem
Given a file test.rb:
# encoding: utf-8# frozen_string_literal: truedefine_method('foo')do |bar|
puts'Completely ignores the argument'endfoo(42)
Running RuboCop gives this output:
Inspecting 1 file
W
Offenses:
test.rb:4:26: W: Unused block argument - bar. You can omit the argument if you don't care about it.
define_method('foo') do |bar|
^^^
1 file inspected, 1 offense detected
…method`
This cop would make recommendations that, if followed, would change
the arity of methods defined using `#define_method`. This change
fixes that.
…method`
This cop would make recommendations that, if followed, would change
the arity of methods defined using `#define_method`. This change
fixes that.
When using
define_method
to define a method, the block arguments given will turn into method arguments on the defined method. So when theLint/UnusedBlockArgument
cop recommends that I “can omit the argument”, it is actually suggesting that I change the arity of a method without changing its callers.Running RuboCop with the
-a
flag does the right thing and prefixes the unused argument with an underscore.Expected behavior
Recommend that I use
_
prefix for unused block argument todefine_method
.Actual behavior
Recommend that I use delete the “unused” block argument to
define_method
.Steps to reproduce the problem
Given a file test.rb:
Running RuboCop gives this output:
RuboCop version
The text was updated successfully, but these errors were encountered: