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
…antMerge`
Fixesrubocop#86.
This PR fixes the following incorrect autocorrect for `Performance/RedundantMerge`
when using an empty hash argument.
```console
% cat example.rb
def something
hash.merge!({}) if blah?
hash
end
% rubocop --only Performance/RedundantMerge -a
Inspecting 1 file
E
Offenses:
example.rb:2:3: C: [Corrected] Performance/RedundantMerge: Use instead
of hash.merge!({}).
hash.merge!({}) if blah?
^^^^^^^^^^^^^^^
example.rb:5:1: E: Lint/Syntax: unexpected token $end
(Using Ruby 2.6 parser; configure using TargetRubyVersion parameter,
under AllCops)
1 file inspected, 2 offenses detected, 1 offense corrected
% cat example.rb
def something
if blah?
hash
end
```
There is no good case code to replace an empty hash argument,
so this PR changes it to not offense.
After autocorrect following code, syntax will be broken.
Expected behavior
Should not break syntax.
Or give up autocorrection.
Actual behavior
Steps to reproduce the problem
Put the code to
test.rb
then:RuboCop version
rubocop-performance is 1.5.1
The text was updated successfully, but these errors were encountered: