Autocorrecting with Performance/BlockGivenWithExplicitBlock
and Lint/UnusedMethodArgument
breaks code
#367
Labels
bug
Something isn't working
When both
Performance/BlockGivenWithExplicitBlock
andLint/UnusedMethodArgument
cops are enabled, there seem to be cases where the autocorrect introduces incorrect behavior. This specifically occurs in method definitions with the following characteristics:block_given?
.Here's a sample code to illustrate the issue:
Expected Behavior
Only one of the cop's autocorrects should be executed. Ideally, the code should be:
or
Actual Behavior
The autocorrect results in:
This leads to the code referencing an undefined variable
block
, thus deviating from the intended functionality.Steps to Reproduce
example.rb
.bundle exec rubocop -a example.rb
.RuboCop Version
The text was updated successfully, but these errors were encountered: