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
Autocorrecting an issue highlighted by Style/InverseMethods cop causes my code to be corrected into something that is not possible to be run.
This is an example file that I've been using to verify the issue - an adapted excerpt from code modifying Spree framework:
test.rb:
Spree::Shipment.class_eval do
state_machine initial: :pending, use_transactions: false do
event :x do
transition from: :y, to: :z, if: lambda { |shipment|
# Fix for #2040
!(shipment.inventory_units.any? &:backordered?)
}
end
end
end
The issue getting highlighted and corrected here is in the line 6th - cop wants to use none? instead of any?.
Expected behavior
Line 6 should be corrected to
shipment.inventory_units.none? &:backordered?
or
(shipment.inventory_units.none? &:backordered?)
Actual behavior
Line 6 got corrected to
shipment.inventory_units.none? &:backordered?)
leaving a closing parenthesis (while the opening one got removed) at the end of the line and breaking the code.
Steps to reproduce the problem
Autofix the above test file with Rubocop config included at the bottom of the issue - I used rubocop --auto-correct app/models/spree/test.rb
Autocorrecting an issue highlighted by Style/InverseMethods cop causes my code to be corrected into something that is not possible to be run.
This is an example file that I've been using to verify the issue - an adapted excerpt from code modifying Spree framework:
test.rb
:The issue getting highlighted and corrected here is in the line 6th - cop wants to use
none?
instead ofany?
.Expected behavior
Line 6 should be corrected to
or
Actual behavior
Line 6 got corrected to
leaving a closing parenthesis (while the opening one got removed) at the end of the line and breaking the code.
Steps to reproduce the problem
rubocop --auto-correct app/models/spree/test.rb
RuboCop version
I also used
rubocop-rails
version 2.4.2My rubocop config:
.rubocop.yml
:The text was updated successfully, but these errors were encountered: