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
describe'problem'dolet(:hash){{foo: 'bar'}}let(:merged){hash.merge!(baz: 'plugh')}it'should have correct contents'doexpect(merged).toeq(foo: 'bar',baz: 'plugh')endend
the auto-correct in 0.37.1 will correct that to use let(:merged) { hash[:baz] = 'plugh' }. The result of the assignment is the string plugh, but the result of the merge! was the hash (now modified).
Maybe Performance/RedundantMerge shouldn't apply if the merge! is the last thing in a block.
21:42 $ bundle exec rubocop --auto-correct --debug --config /dev/null bug_spec.rb
configuration from /dev/null
Default configuration from /Users/mike/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.37.1/config/default.yml
Inheriting configuration from /Users/mike/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.37.1/config/enabled.yml
Inheriting configuration from /Users/mike/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.37.1/config/disabled.yml
Inspecting 1 file
Scanning /Users/mike/Projects/influitive/hub/bug_spec.rb
C
Offenses:
bug_spec.rb:3:18: C: [Corrected] Performance/RedundantMerge: Use hash[:baz] = 'plugh' instead of hash.merge!(baz: 'plugh').
let(:merged) { hash.merge!(baz: 'plugh') }
^^^^^^^^^^^^^^^^^^^^^^^^^
1 file inspected, 1 offense detected, 1 offense corrected
Finished in 0.3582553739834111 seconds
$ cat bug_spec.rb
describe 'problem' do
let(:hash) { { foo: 'bar' } }
let(:merged) { hash[:baz] = 'plugh' }
it 'should have correct contents' do
expect(merged).to eq(foo: 'bar', baz: 'plugh')
end
end
The text was updated successfully, but these errors were encountered:
Consider an rspec spec file:
the auto-correct in 0.37.1 will correct that to use
let(:merged) { hash[:baz] = 'plugh' }
. The result of the assignment is the stringplugh
, but the result of themerge!
was the hash (now modified).Maybe
Performance/RedundantMerge
shouldn't apply if themerge!
is the last thing in a block.The text was updated successfully, but these errors were encountered: