the cop identifies the method sort_by as a paramater
Unknown what the purpose of the cop exactly is
verify.rb:59:8: W: Parenthesize the param sort_by to make sure that the block will be associated with the != method call.
error('section.yml is not alphabetized by name') \
if sections != sections.sort_by { |section| section['id'].downcase }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
git checkout https://github.com/2factorauth/twofactorauth -b 51df6e1
bundle install
bundle exec rake
Using rubocop 0.48.0
Same mistake happens for common rspec assertions like:
expect(deliver).not_to change { GuestListMembership.count }
Where parenthesize seems also not needed
Where parenthesize seems also not needed
This example is different - it this DSL that's completely fine, but it might have also been an actual oversight. The cop can't possible tell those apart. I'm advising people to simply disable the cop when needed in such cases. Or we can add some method exceptions list. At any rate - that's a different problem.
Thanks for quick answer, in my case I've decided to fix it refactoring to:
expect(deliver).not_to change(GuestListMembership, :count)
But you may consider putting exception I guess... this is looks like common case to me.
As well rubocop raises only with expect().not_to same with expect().to doesn't raise this error.
@dzirtusss I'm seeing the exact same thing here, barks only on expect().not_to
Most helpful comment
Thanks for quick answer, in my case I've decided to fix it refactoring to:
But you may consider putting exception I guess... this is looks like common case to me.