openfoodfoundation / openfoodnetwork

Connect suppliers, distributors and consumers to trade local produce.
https://www.openfoodnetwork.org
GNU Affero General Public License v3.0
1.1k stars 716 forks source link

Rubocop: app/controllers/split_checkout_controller.rb has too many lines #8942

Closed jibees closed 1 year ago

jibees commented 2 years ago

What we should change and why (this is tech debt)

Rubocop warning about the length of the class split_checkout_contoller.rb

Context

This came up in PR https://github.com/openfoodfoundation/openfoodnetwork/pull/8893#issuecomment-1048313464

macanudo527 commented 1 year ago

@jibees I'd like to give this a try.

EDIT: link for reference - https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/controllers/split_checkout_controller.rb

macanudo527 commented 1 year ago

I think we can isolate all the methods that handle errors into a service. It seems like all of these are related:

render_error
order_error_messages
no_ship_address_needed?
remove_ship_address_errors
reorder_errors
bill_address_error_order
flash_error_when_no_shipping_method_available

And then maybe we can extract the voucher processing? That should come close to 100 lines.

Or there was talk of splitting this into two controllers. Is that the better solution here?