From bb728d97fdc51d558522f283c536b0a04e206111 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 20 Jul 2023 13:46:52 +1000 Subject: [PATCH 01/11] Regenerate Rubocop's TODO file --- .rubocop_todo.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 727207a1d3..2024e7c8b2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400 --no-auto-gen-timestamp` -# using RuboCop version 1.54.1. +# using RuboCop version 1.54.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -81,6 +81,15 @@ Layout/EmptyLinesAroundBlockBody: Exclude: - 'spec/system/admin/order_cycles/list_spec.rb' +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. +Layout/ExtraSpacing: + Exclude: + - 'spec/lib/open_food_network/property_merge_spec.rb' + - 'spec/services/cart_service_spec.rb' + - 'spec/system/consumer/shops_spec.rb' + # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. @@ -211,7 +220,7 @@ Layout/TrailingEmptyLines: Exclude: - 'Rakefile' -# Offense count: 76 +# Offense count: 77 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowInHeredoc. Layout/TrailingWhitespace: @@ -416,7 +425,7 @@ Metrics/AbcSize: - 'lib/tasks/enterprises.rake' - 'spec/services/order_checkout_restart_spec.rb' -# Offense count: 45 +# Offense count: 46 # Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. # AllowedMethods: refine Metrics/BlockLength: @@ -1376,7 +1385,7 @@ Style/HashLikeCase: Exclude: - 'app/models/enterprise.rb' -# Offense count: 1782 +# Offense count: 1783 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys From bcfa70af4e3f32f819da6b1a303b3b892a1ee0d6 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 20 Jul 2023 13:48:51 +1000 Subject: [PATCH 02/11] Safely autocorrect Layout/ArgumentAlignment Inspecting 1478 files ...................................................................................................................................................C..C.......................................................................................................C........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C..........................................C................................................................................................................................................................................................C..................................................................C............C..................CC............................................C......C.......................... Offenses: app/controllers/spree/users_controller.rb:37:15: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. locals: { type: "alert", message: t('devise.failure.already_registered') }) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ app/controllers/spree/users_controller.rb:52:13: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. locals: { type: "success", ... ^^^^^^^^^^^^^^^^^^^^^^^^^^ app/controllers/user_confirmations_controller.rb:28:11: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. locals: { type: "success", message: t("devise.confirmations.send_instructions") }) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ app/models/enterprise.rb:54:5: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. inverse_of: :distributor, foreign_key: :distributor_id ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ app/models/enterprise.rb:56:5: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. inverse_of: :distributor, foreign_key: :distributor_id ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ app/models/enterprise.rb:118:5: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. format: { ... ^^^^^^^^^ spec/lib/reports/packing/packing_report_spec.rb:60:11: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. product: create(:simple_product, name: "visible", supplier: supplier1)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/lib/reports/packing/packing_report_spec.rb:64:11: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. product: create(:simple_product, name: "not visible", supplier: supplier2)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/migrations/migrate_customer_names_spec.rb:16:7: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise1.id}") ^^^^^^^^^^^^^^^^^^^^^ spec/migrations/migrate_customer_names_spec.rb:16:101: C: Layout/LineLength: Line is too long. [122/100] value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise1.id}") ^^^^^^^^^^^^^^^^^^^^^^ spec/migrations/migrate_customer_names_spec.rb:18:7: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise2.id}") ^^^^^^^^^^^^^^^^^^^^^ spec/migrations/migrate_customer_names_spec.rb:18:101: C: Layout/LineLength: Line is too long. [122/100] value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise2.id}") ^^^^^^^^^^^^^^^^^^^^^^ spec/migrations/migrate_customer_names_spec.rb:20:7: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise4.id}") ^^^^^^^^^^^^^^^^^^^^^ spec/migrations/migrate_customer_names_spec.rb:20:101: C: Layout/LineLength: Line is too long. [122/100] value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise4.id}") ^^^^^^^^^^^^^^^^^^^^^^ spec/services/products_renderer_spec.rb:91:13: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. { q: { with_properties: [property_organic.id] } }) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/services/products_renderer_spec.rb:91:101: C: Layout/LineLength: Line is too long. [101/100] { q: { with_properties: [property_organic.id] } }) ^ spec/services/products_renderer_spec.rb:100:13: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. { q: { with_properties: [property_organic.id] } }) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/services/products_renderer_spec.rb:100:101: C: Layout/LineLength: Line is too long. [101/100] { q: { with_properties: [property_organic.id] } }) ^ spec/services/products_renderer_spec.rb:118:13: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. { q: { with_properties: [property_organic.id] } }) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/services/products_renderer_spec.rb:118:101: C: Layout/LineLength: Line is too long. [101/100] { q: { with_properties: [property_organic.id] } }) ^ spec/system/admin/bulk_order_management_spec.rb:268:11: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. text: "#{o1.bill_address.last_name}, #{o1.bill_address.first_name}" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/system/admin/bulk_order_management_spec.rb:793:9: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. retry: 3 do ^^^^^^^^ spec/system/admin/enterprise_fees_spec.rb:103:9: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. from: "#{prefix}_tax_category_id" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/system/admin/enterprise_fees_spec.rb:129:9: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. from: "#{prefix}_calculator_type" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/system/admin/enterprise_fees_spec.rb:133:9: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. from: "#{prefix}_calculator_type" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/system/admin/enterprise_fees_spec.rb:160:9: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. from: "#{prefix}_calculator_type" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/system/admin/enterprise_fees_spec.rb:221:13: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. selected: 'Second Distributor' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/system/admin/enterprise_fees_spec.rb:232:43: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. 'Flat Rate (per order)', message, 0 ^^^^^^^^^^^^^^^^^^^^^^^ spec/system/admin/order_cycles/list_spec.rb:148:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. match: :first).value).to start_with oc_open_at.strftime("%Y-%m-%d %H:%M") ^^^^^^^^^^^^^ spec/system/admin/order_cycles/list_spec.rb:161:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. match: :first).value).to eq oc_open_at.strftime("%Y-%m-13 %H:%M") ^^^^^^^^^^^^^ spec/system/admin/order_cycles/list_spec.rb:189:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. match: :first).value).to eq test_value.to_datetime.strftime("%Y-%m-%d %H:%M") ^^^^^^^^^^^^^ spec/system/admin/order_cycles/simple_spec.rb:346:13: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. with_options: [schedule_of_other_managed_distributor.name] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/system/admin/order_cycles/simple_spec.rb:346:101: C: Layout/LineLength: Line is too long. [101/100] with_options: [schedule_of_other_managed_distributor.name] ^ spec/system/admin/order_cycles/simple_spec.rb:623:9: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. value: Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0).strftime("%F %T %z"), visible: false ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/system/admin/order_cycles/simple_spec.rb:623:101: C: Layout/LineLength: Line is too long. [121/100] value: Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0).strftime("%F %T %z"), visible: false ^^^^^^^^^^^^^^^^^^^^^ spec/system/admin/order_cycles/simple_spec.rb:625:9: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z"), visible: false ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/system/admin/order_cycles/simple_spec.rb:625:101: C: Layout/LineLength: Line is too long. [120/100] value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z"), visible: false ^^^^^^^^^^^^^^^^^^^^ spec/system/admin/order_cycles/simple_spec.rb:733:9: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. value: Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0).strftime("%F %T %z"), visible: false ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/system/admin/order_cycles/simple_spec.rb:733:101: C: Layout/LineLength: Line is too long. [121/100] value: Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0).strftime("%F %T %z"), visible: false ^^^^^^^^^^^^^^^^^^^^^ spec/system/admin/order_cycles/simple_spec.rb:735:9: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z"), visible: false ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/system/admin/order_cycles/simple_spec.rb:735:101: C: Layout/LineLength: Line is too long. [120/100] value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z"), visible: false ^^^^^^^^^^^^^^^^^^^^ spec/system/consumer/shopping/cart_spec.rb:147:35: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. preferred_unit_from_list: "kg"), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/system/consumer/shopping/cart_spec.rb:147:101: C: Layout/LineLength: Line is too long. [101/100] preferred_unit_from_list: "kg"), ^ spec/system/consumer/shopping/products_spec.rb:98:11: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. "", truncate: false) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/system/consumer/shopping/products_spec.rb:98:101: C: Layout/LineLength: Line is too long. [113/100] "", truncate: false) ^^^^^^^^^^^^^ 1478 files inspected, 45 offenses detected, 32 offenses corrected --- .rubocop_todo.yml | 19 ------------------- app/controllers/spree/users_controller.rb | 6 +++--- .../user_confirmations_controller.rb | 2 +- app/models/enterprise.rb | 12 ++++++------ .../reports/packing/packing_report_spec.rb | 4 ++-- .../migrations/migrate_customer_names_spec.rb | 6 +++--- spec/services/products_renderer_spec.rb | 6 +++--- .../admin/bulk_order_management_spec.rb | 4 ++-- spec/system/admin/enterprise_fees_spec.rb | 12 ++++++------ spec/system/admin/order_cycles/list_spec.rb | 6 +++--- spec/system/admin/order_cycles/simple_spec.rb | 10 +++++----- spec/system/consumer/shopping/cart_spec.rb | 2 +- .../system/consumer/shopping/products_spec.rb | 2 +- 13 files changed, 36 insertions(+), 55 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2024e7c8b2..6c80f6e0ca 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -16,25 +16,6 @@ Gemspec/RequiredRubyVersion: - 'engines/order_management/order_management.gemspec' - 'engines/web/web.gemspec' -# Offense count: 32 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: with_first_argument, with_fixed_indentation -Layout/ArgumentAlignment: - Exclude: - - 'app/controllers/spree/users_controller.rb' - - 'app/controllers/user_confirmations_controller.rb' - - 'app/models/enterprise.rb' - - 'spec/lib/reports/packing/packing_report_spec.rb' - - 'spec/migrations/migrate_customer_names_spec.rb' - - 'spec/services/products_renderer_spec.rb' - - 'spec/system/admin/bulk_order_management_spec.rb' - - 'spec/system/admin/enterprise_fees_spec.rb' - - 'spec/system/admin/order_cycles/list_spec.rb' - - 'spec/system/admin/order_cycles/simple_spec.rb' - - 'spec/system/consumer/shopping/cart_spec.rb' - - 'spec/system/consumer/shopping/products_spec.rb' - # Offense count: 4 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. diff --git a/app/controllers/spree/users_controller.rb b/app/controllers/spree/users_controller.rb index 2ca8127807..cba00ac922 100644 --- a/app/controllers/spree/users_controller.rb +++ b/app/controllers/spree/users_controller.rb @@ -34,7 +34,7 @@ module Spree inner_html( "#login-feedback", partial("layouts/alert", - locals: { type: "alert", message: t('devise.failure.already_registered') }) + locals: { type: "alert", message: t('devise.failure.already_registered') }) ). dispatch_event(name: "login:modal:open") else @@ -49,8 +49,8 @@ module Spree render cable_ready: cable_car.inner_html( "#signup-feedback", partial("layouts/alert", - locals: { type: "success", - message: t('devise.user_registrations.spree_user.signed_up_but_unconfirmed') }) + locals: { type: "success", + message: t('devise.user_registrations.spree_user.signed_up_but_unconfirmed') }) ) else render status: :unprocessable_entity, cable_ready: cable_car.morph( diff --git a/app/controllers/user_confirmations_controller.rb b/app/controllers/user_confirmations_controller.rb index b36e522cd8..dd07d9d299 100644 --- a/app/controllers/user_confirmations_controller.rb +++ b/app/controllers/user_confirmations_controller.rb @@ -25,7 +25,7 @@ class UserConfirmationsController < DeviseController render cable_ready: cable_car.inner_html( "##{params[:tab] || 'forgot'}-feedback", partial("layouts/alert", - locals: { type: "success", message: t("devise.confirmations.send_instructions") }) + locals: { type: "success", message: t("devise.confirmations.send_instructions") }) ) return end diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 7eb06670b4..a35eadf9fd 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -51,9 +51,9 @@ class Enterprise < ApplicationRecord belongs_to :owner, class_name: 'Spree::User', inverse_of: :owned_enterprises has_many :distributor_payment_methods, - inverse_of: :distributor, foreign_key: :distributor_id + inverse_of: :distributor, foreign_key: :distributor_id has_many :distributor_shipping_methods, - inverse_of: :distributor, foreign_key: :distributor_id + inverse_of: :distributor, foreign_key: :distributor_id has_many :payment_methods, through: :distributor_payment_methods has_many :shipping_methods, through: :distributor_shipping_methods has_many :customers @@ -115,10 +115,10 @@ class Enterprise < ApplicationRecord validate :shopfront_producers validate :enforce_ownership_limit, if: lambda { owner_id_changed? && !owner_id.nil? } validates :instagram, - format: { - with: VALID_INSTAGRAM_REGEX, - message: Spree.t('errors.messages.invalid_instagram_url') - }, allow_blank: true + format: { + with: VALID_INSTAGRAM_REGEX, + message: Spree.t('errors.messages.invalid_instagram_url') + }, allow_blank: true validate :validate_white_label_logo_link before_validation :initialize_permalink, if: lambda { permalink.nil? } diff --git a/spec/lib/reports/packing/packing_report_spec.rb b/spec/lib/reports/packing/packing_report_spec.rb index a21ee323fe..087788bffc 100644 --- a/spec/lib/reports/packing/packing_report_spec.rb +++ b/spec/lib/reports/packing/packing_report_spec.rb @@ -57,11 +57,11 @@ describe "Packing Reports" do } let(:line_item2) { build(:line_item_with_shipment, - product: create(:simple_product, name: "visible", supplier: supplier1)) + product: create(:simple_product, name: "visible", supplier: supplier1)) } let(:line_item3) { build(:line_item_with_shipment, - product: create(:simple_product, name: "not visible", supplier: supplier2)) + product: create(:simple_product, name: "not visible", supplier: supplier2)) } before do diff --git a/spec/migrations/migrate_customer_names_spec.rb b/spec/migrations/migrate_customer_names_spec.rb index a636dfb8a6..00f1224d11 100644 --- a/spec/migrations/migrate_customer_names_spec.rb +++ b/spec/migrations/migrate_customer_names_spec.rb @@ -13,11 +13,11 @@ describe MigrateCustomerNames do before do Spree::Preference.create(value: true, - value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise1.id}") + value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise1.id}") Spree::Preference.create(value: false, - value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise2.id}") + value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise2.id}") Spree::Preference.create(value: true, - value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise4.id}") + value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise4.id}") end describe '#migrate_customer_names_preferences!' do diff --git a/spec/services/products_renderer_spec.rb b/spec/services/products_renderer_spec.rb index 3dc0fde48a..89536b48a5 100644 --- a/spec/services/products_renderer_spec.rb +++ b/spec/services/products_renderer_spec.rb @@ -88,7 +88,7 @@ describe ProductsRenderer do product_apples.product_properties.create!({ property_id: property_organic.id, value: '1', position: 1 }) products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, - { q: { with_properties: [property_organic.id] } }) + { q: { with_properties: [property_organic.id] } }) products = products_renderer.send(:products) expect(products).to eq([product_apples]) end @@ -97,7 +97,7 @@ describe ProductsRenderer do fruits_supplier.producer_properties.create!({ property_id: property_organic.id, value: '1', position: 1 }) products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, - { q: { with_properties: [property_organic.id] } }) + { q: { with_properties: [property_organic.id] } }) products = products_renderer.send(:products) expect(products).to eq([product_apples, product_cherries]) end @@ -115,7 +115,7 @@ describe ProductsRenderer do product_doughnuts.product_properties.create!({ property_id: property_organic.id, value: '1', position: 1 }) products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, - { q: { with_properties: [property_organic.id] } }) + { q: { with_properties: [property_organic.id] } }) products = products_renderer.send(:products) expect(products).to eq([product_cherries, product_banana_bread, product_doughnuts]) end diff --git a/spec/system/admin/bulk_order_management_spec.rb b/spec/system/admin/bulk_order_management_spec.rb index 03587f4b25..4006c03f15 100644 --- a/spec/system/admin/bulk_order_management_spec.rb +++ b/spec/system/admin/bulk_order_management_spec.rb @@ -265,7 +265,7 @@ describe ' it "displays a column for user's full name" do expect(page).to have_selector "th.full_name", text: "NAME" expect(page).to have_selector "td.full_name", - text: "#{o1.bill_address.last_name}, #{o1.bill_address.first_name}" + text: "#{o1.bill_address.last_name}, #{o1.bill_address.first_name}" expect(page).to have_selector "td.full_name", text: "" end @@ -790,7 +790,7 @@ describe ' end it "displays only line items whose orders meet the date restriction criteria, when changed", - retry: 3 do + retry: 3 do from = today - 8.days to = today + 1.day diff --git a/spec/system/admin/enterprise_fees_spec.rb b/spec/system/admin/enterprise_fees_spec.rb index a9b5e1b7d5..0669db1418 100644 --- a/spec/system/admin/enterprise_fees_spec.rb +++ b/spec/system/admin/enterprise_fees_spec.rb @@ -100,7 +100,7 @@ describe ' select 'Admin', from: "#{prefix}_fee_type" fill_in "#{prefix}_name", with: 'Greetings!' select 'Inherit From Product', - from: "#{prefix}_tax_category_id" + from: "#{prefix}_tax_category_id" select 'Flat Percent', from: "#{prefix}_calculator_type" click_button 'Update' end @@ -126,11 +126,11 @@ describe ' it "handle when updating calculator type for Weight to Flat Rate" do select 'Weight (per kg or lb)', - from: "#{prefix}_calculator_type" + from: "#{prefix}_calculator_type" click_button 'Update' select 'Flat Rate (per item)', - from: "#{prefix}_calculator_type" + from: "#{prefix}_calculator_type" click_button 'Update' expect(fee.reload.calculator_type).to eq("Calculator::PerItem") @@ -157,7 +157,7 @@ describe ' # editing to an invalid combination select 'Flat Rate (per order)', - from: "#{prefix}_calculator_type" + from: "#{prefix}_calculator_type" expect{ click_button 'Update' }.to_not change { fee.reload.calculator_type } expect(page).to have_content "Inheriting the tax categeory requires a per-item calculator." end @@ -218,7 +218,7 @@ describe ' # After saving, we should be redirected to the fees for our chosen enterprise expect(page). not_to have_select 'sets_enterprise_fee_set_collection_attributes_1_enterprise_id', - selected: 'Second Distributor' + selected: 'Second Distributor' # A new enterprise fee is created expect(EnterpriseFee.count).to eq(fee_count) @@ -229,7 +229,7 @@ describe ' context "an error message is displayed" do message = 'Inheriting the tax categeory requires a per-item calculator.' it_behaves_like "setting it up", 'Inherit From Product', - 'Flat Rate (per order)', message, 0 + 'Flat Rate (per order)', message, 0 end context "an success message is displayed" do diff --git a/spec/system/admin/order_cycles/list_spec.rb b/spec/system/admin/order_cycles/list_spec.rb index bf91063bbe..d69bc53fe8 100644 --- a/spec/system/admin/order_cycles/list_spec.rb +++ b/spec/system/admin/order_cycles/list_spec.rb @@ -145,7 +145,7 @@ describe ' within("tr.order-cycle-#{oc_pt.id}") do expect(find('input.datetimepicker', -match: :first).value).to start_with oc_open_at.strftime("%Y-%m-%d %H:%M") + match: :first).value).to start_with oc_open_at.strftime("%Y-%m-%d %H:%M") find('input.datetimepicker', match: :first).click end @@ -158,7 +158,7 @@ match: :first).value).to start_with oc_open_at.strftime("%Y-%m-%d %H:%M") within("tr.order-cycle-#{oc_pt.id}") do expect(find('input.datetimepicker', -match: :first).value).to eq oc_open_at.strftime("%Y-%m-13 %H:%M") + match: :first).value).to eq oc_open_at.strftime("%Y-%m-13 %H:%M") end end @@ -186,7 +186,7 @@ match: :first).value).to eq oc_open_at.strftime("%Y-%m-13 %H:%M") # Check the value is correct within("tr.order-cycle-#{oc_pt.id}") do expect(find('input.datetimepicker', -match: :first).value).to eq test_value.to_datetime.strftime("%Y-%m-%d %H:%M") + match: :first).value).to eq test_value.to_datetime.strftime("%Y-%m-%d %H:%M") end end diff --git a/spec/system/admin/order_cycles/simple_spec.rb b/spec/system/admin/order_cycles/simple_spec.rb index de1938f32b..ec993e9d91 100644 --- a/spec/system/admin/order_cycles/simple_spec.rb +++ b/spec/system/admin/order_cycles/simple_spec.rb @@ -343,7 +343,7 @@ describe ' expect(page).to have_field 'order_cycle_name', with: oc.name select2_select schedule.name, from: 'schedule_ids' expect(page).not_to have_select2 'schedule_ids', - with_options: [schedule_of_other_managed_distributor.name] + with_options: [schedule_of_other_managed_distributor.name] click_button 'Save and Next' @@ -620,9 +620,9 @@ describe ' expect(page).to have_input "oc#{oc.id}[name]", value: "Plums & Avos" expect(page).to have_input "oc#{oc.id}[orders_open_at]", - value: Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0).strftime("%F %T %z"), visible: false + value: Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0).strftime("%F %T %z"), visible: false expect(page).to have_input "oc#{oc.id}[orders_close_at]", - value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z"), visible: false + value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z"), visible: false # And it should have some variants selected expect(oc.exchanges.incoming.first.variants.count).to eq(2) @@ -730,9 +730,9 @@ describe ' expect(page).to have_input "oc#{oc.id}[name]", value: "Plums & Avos" expect(page).to have_input "oc#{oc.id}[orders_open_at]", - value: Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0).strftime("%F %T %z"), visible: false + value: Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0).strftime("%F %T %z"), visible: false expect(page).to have_input "oc#{oc.id}[orders_close_at]", - value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z"), visible: false + value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z"), visible: false # And it should have a variant selected expect(oc.exchanges.incoming.first.variants).to eq([v2]) diff --git a/spec/system/consumer/shopping/cart_spec.rb b/spec/system/consumer/shopping/cart_spec.rb index 0fccd29cd1..1de6615928 100644 --- a/spec/system/consumer/shopping/cart_spec.rb +++ b/spec/system/consumer/shopping/cart_spec.rb @@ -144,7 +144,7 @@ describe "full-page cart" do context "order with 2 line items" do let(:admin_fee) { create(:enterprise_fee, calculator: Calculator::Weight.new(preferred_per_unit: 1, - preferred_unit_from_list: "kg"), + preferred_unit_from_list: "kg"), enterprise: order_cycle.coordinator, fee_type: 'admin') } diff --git a/spec/system/consumer/shopping/products_spec.rb b/spec/system/consumer/shopping/products_spec.rb index 59856aad03..5f570358a8 100644 --- a/spec/system/consumer/shopping/products_spec.rb +++ b/spec/system/consumer/shopping/products_spec.rb @@ -95,7 +95,7 @@ describe "As a consumer I want to view products" do expect(page).to have_content product.name expect_product_description_html_to_be_displayed(product, "

Safe

", - "", truncate: false) + "", truncate: false) end end From 5a3a4a041fb314bd1fcaef1a7f75fb297cd67892 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 20 Jul 2023 13:50:55 +1000 Subject: [PATCH 03/11] Safely autocorrect Layout/ArrayAlignment Inspecting 1478 files ..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C......................CC.........................................C................................. Offenses: spec/system/admin/customers_spec.rb:40:13: C: [Corrected] Layout/ArrayAlignment: Align the elements of an array literal if they span more than one line. managed_distributor2.name], without_options: [unmanaged_distributor.name] ^^^^^^^^^^^^^^^^^^^^^^^^^ spec/system/admin/customers_spec.rb:40:101: C: Layout/LineLength: Line is too long. [126/100] managed_distributor2.name], without_options: [unmanaged_distributor.name] ^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/system/admin/order_spec.rb:742:1: C: [Corrected] Layout/ArrayAlignment: Align the elements of an array literal if they span more than one line. different_shipping_method_for_distributor1] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/system/admin/orders_spec.rb:48:33: C: [Corrected] Layout/ArrayAlignment: Align the elements of an array literal if they span more than one line. distributor3, distributor4], ^^^^^^^^^^^^ spec/system/consumer/shopping/cart_spec.rb:21:37: C: [Corrected] Layout/ArrayAlignment: Align the elements of an array literal if they span more than one line. product_with_fee.variants.first]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1478 files inspected, 5 offenses detected, 4 offenses corrected --- .rubocop_todo.yml | 22 +++++++--------------- spec/system/admin/customers_spec.rb | 2 +- spec/system/admin/order_spec.rb | 2 +- spec/system/admin/orders_spec.rb | 2 +- spec/system/consumer/shopping/cart_spec.rb | 2 +- 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6c80f6e0ca..93241451a0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -16,17 +16,6 @@ Gemspec/RequiredRubyVersion: - 'engines/order_management/order_management.gemspec' - 'engines/web/web.gemspec' -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: with_first_element, with_fixed_indentation -Layout/ArrayAlignment: - Exclude: - - 'spec/system/admin/customers_spec.rb' - - 'spec/system/admin/order_spec.rb' - - 'spec/system/admin/orders_spec.rb' - - 'spec/system/consumer/shopping/cart_spec.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleAlignWith. @@ -87,7 +76,7 @@ Layout/FirstHashElementIndentation: Exclude: - 'spec/services/products_renderer_spec.rb' -# Offense count: 13 +# Offense count: 9 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. # SupportedHashRocketStyles: key, separator, table @@ -96,13 +85,11 @@ Layout/FirstHashElementIndentation: Layout/HashAlignment: Exclude: - 'app/controllers/spree/users_controller.rb' - - 'spec/migrations/migrate_customer_names_spec.rb' - 'spec/models/enterprise_spec.rb' - 'spec/system/admin/customers_spec.rb' - 'spec/system/admin/order_spec.rb' - 'spec/system/admin/orders_spec.rb' - 'spec/system/admin/tag_rules_spec.rb' - - 'spec/system/consumer/shopping/cart_spec.rb' # Offense count: 4 # This cop supports safe autocorrection (--autocorrect). @@ -137,7 +124,7 @@ Layout/LineContinuationSpacing: - 'spec/system/admin/enterprise_fees_spec.rb' - 'spec/system/admin/order_spec.rb' -# Offense count: 77 +# Offense count: 91 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # URISchemes: http, https @@ -151,6 +138,7 @@ Layout/LineLength: - 'spec/controllers/api/v0/order_cycles_controller_spec.rb' - 'spec/controllers/spree/admin/orders_controller_spec.rb' - 'spec/lib/reports/customers_report_spec.rb' + - 'spec/migrations/migrate_customer_names_spec.rb' - 'spec/models/enterprise_spec.rb' - 'spec/models/order_cycle_spec.rb' - 'spec/models/product_importer_spec.rb' @@ -160,11 +148,15 @@ Layout/LineLength: - 'spec/models/spree/product_spec.rb' - 'spec/models/spree/variant_spec.rb' - 'spec/requests/api/orders_spec.rb' + - 'spec/services/products_renderer_spec.rb' - 'spec/support/request/web_helper.rb' - 'spec/system/admin/adjustments_spec.rb' - 'spec/system/admin/bulk_order_management_spec.rb' + - 'spec/system/admin/order_cycles/simple_spec.rb' - 'spec/system/admin/order_spec.rb' - 'spec/system/admin/product_import_spec.rb' + - 'spec/system/consumer/shopping/cart_spec.rb' + - 'spec/system/consumer/shopping/products_spec.rb' # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). diff --git a/spec/system/admin/customers_spec.rb b/spec/system/admin/customers_spec.rb index 59b5b16a86..acdd9497c3 100644 --- a/spec/system/admin/customers_spec.rb +++ b/spec/system/admin/customers_spec.rb @@ -37,7 +37,7 @@ code: nil, created_manually: true) # Prompts for a hub for a list of my managed enterprises expect(page) .to have_select2 "shop_id", with_options: [managed_distributor1.name, - managed_distributor2.name], without_options: [unmanaged_distributor.name] + managed_distributor2.name], without_options: [unmanaged_distributor.name] select2_select managed_distributor2.name, from: "shop_id" diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index 7452546b2b..c64b13e1bb 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -739,7 +739,7 @@ distributors: [distributor1]) "in an existing order " do before do distributor1.shipping_methods = [shipping_method_for_distributor1, -different_shipping_method_for_distributor1] + different_shipping_method_for_distributor1] order.shipments.each(&:refresh_rates) order.shipment.adjustments.first.open order.select_shipping_method(different_shipping_method_for_distributor1) diff --git a/spec/system/admin/orders_spec.rb b/spec/system/admin/orders_spec.rb index e64cd0b5de..3ce0295b36 100644 --- a/spec/system/admin/orders_spec.rb +++ b/spec/system/admin/orders_spec.rb @@ -45,7 +45,7 @@ describe ' distributors: [distributor4, distributor5]) } let(:order_cycle) do create(:simple_order_cycle, name: 'One', distributors: [distributor, distributor2, - distributor3, distributor4], + distributor3, distributor4], variants: [product.variants.first]) end diff --git a/spec/system/consumer/shopping/cart_spec.rb b/spec/system/consumer/shopping/cart_spec.rb index 1de6615928..6e24698cd7 100644 --- a/spec/system/consumer/shopping/cart_spec.rb +++ b/spec/system/consumer/shopping/cart_spec.rb @@ -18,7 +18,7 @@ describe "full-page cart" do create(:simple_order_cycle, suppliers: [supplier], distributors: [distributor], coordinator: create(:distributor_enterprise), variants: [product_with_tax.variants.first, - product_with_fee.variants.first]) + product_with_fee.variants.first]) } let(:enterprise_fee) { create(:enterprise_fee, amount: 11.00, tax_category: product_with_tax.tax_category) From 7cbe1d94ad5fa57228fc59d3702ed0fb1af3aad5 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 20 Jul 2023 13:52:44 +1000 Subject: [PATCH 04/11] Safely autocorrect Layout/BlockAlignment Inspecting 1478 files ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.................................................................................................................................................................................. Offenses: spec/services/products_renderer_spec.rb:28:7: C: [Corrected] Layout/BlockAlignment: } at 28, 6 is not aligned with let!(:product_cherries) { at 25, 4. } ^ 1478 files inspected, 1 offense detected, 1 offense corrected --- .rubocop_todo.yml | 11 ++--------- spec/services/products_renderer_spec.rb | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 93241451a0..2c30eb3586 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -16,14 +16,6 @@ Gemspec/RequiredRubyVersion: - 'engines/order_management/order_management.gemspec' - 'engines/web/web.gemspec' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleAlignWith. -# SupportedStylesAlignWith: either, start_of_block, start_of_line -Layout/BlockAlignment: - Exclude: - - 'spec/services/products_renderer_spec.rb' - # Offense count: 4 # This cop supports safe autocorrection (--autocorrect). Layout/BlockEndNewline: @@ -124,7 +116,7 @@ Layout/LineContinuationSpacing: - 'spec/system/admin/enterprise_fees_spec.rb' - 'spec/system/admin/order_spec.rb' -# Offense count: 91 +# Offense count: 92 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # URISchemes: http, https @@ -152,6 +144,7 @@ Layout/LineLength: - 'spec/support/request/web_helper.rb' - 'spec/system/admin/adjustments_spec.rb' - 'spec/system/admin/bulk_order_management_spec.rb' + - 'spec/system/admin/customers_spec.rb' - 'spec/system/admin/order_cycles/simple_spec.rb' - 'spec/system/admin/order_spec.rb' - 'spec/system/admin/product_import_spec.rb' diff --git a/spec/services/products_renderer_spec.rb b/spec/services/products_renderer_spec.rb index 89536b48a5..78ec2aae8e 100644 --- a/spec/services/products_renderer_spec.rb +++ b/spec/services/products_renderer_spec.rb @@ -25,7 +25,7 @@ describe ProductsRenderer do let!(:product_cherries) { create(:product, name: "cherries", primary_taxon_id: fruits.id, supplier_id: fruits_supplier.id) - } + } let!(:product_doughnuts) { create(:product, name: "doughnuts", primary_taxon_id: cakes.id, supplier_id: cakes_supplier.id) From 0030343897196a9684c0d2f17d597de9e21c8798 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 20 Jul 2023 13:54:30 +1000 Subject: [PATCH 05/11] Safely autocorrect Layout/BlockEndNewline Inspecting 1478 files ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C...................................................................................................................................................................................................................................................................................................................................................................................C........................................................................... Offenses: spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:127:1: C: [Corrected] Layout/IndentationWidth: Use 2 (not 10) spaces for indentation. create(:enterprise_fee, fee_type: 'packing', amount: 7.89, name: "Packing") ^^^^^^^^^^ spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:127:3: C: [Corrected] Layout/IndentationWidth: Use 2 (not -6) spaces for indentation. create(:enterprise_fee, fee_type: 'packing', amount: 7.89, name: "Packing") ^^^^^^ spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:127:87: C: [Corrected] Layout/BlockEndNewline: Expression at 127, 87 should be on its own line. create(:enterprise_fee, fee_type: 'packing', amount: 7.89, name: "Packing") } ^ spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:128:1: C: [Corrected] Layout/BlockAlignment: } at 128, 0 is not aligned with let!(:ef_packing) { at 126, 8. } ^ spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:129:91: C: [Corrected] Layout/BlockEndNewline: Expression at 129, 91 should be on its own line. create(:enterprise_fee, fee_type: 'transport', amount: 0.12, name: "Transport") } ^ spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:130:1: C: [Corrected] Layout/IndentationWidth: Use 2 (not 10) spaces for indentation. create(:enterprise_fee, fee_type: 'transport', amount: 0.12, name: "Transport") ^^^^^^^^^^ spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:130:3: C: [Corrected] Layout/IndentationWidth: Use 2 (not -6) spaces for indentation. create(:enterprise_fee, fee_type: 'transport', amount: 0.12, name: "Transport") ^^^^^^ spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:131:1: C: [Corrected] Layout/BlockAlignment: } at 131, 0 is not aligned with let!(:ef_transport) { at 129, 8. } ^ spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:131:95: C: [Corrected] Layout/BlockEndNewline: Expression at 131, 95 should be on its own line. create(:enterprise_fee, fee_type: 'fundraising', amount: 3.45, name: "Fundraising") } ^ spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:133:1: C: [Corrected] Layout/IndentationWidth: Use 2 (not 10) spaces for indentation. create(:enterprise_fee, fee_type: 'fundraising', amount: 3.45, name: "Fundraising") ^^^^^^^^^^ spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:133:3: C: [Corrected] Layout/IndentationWidth: Use 2 (not -6) spaces for indentation. create(:enterprise_fee, fee_type: 'fundraising', amount: 3.45, name: "Fundraising") ^^^^^^ spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:134:1: C: [Corrected] Layout/BlockAlignment: } at 134, 0 is not aligned with let!(:ef_fundraising) { at 132, 8. } ^ spec/system/admin/orders_spec.rb:44:1: C: [Corrected] Layout/IndentationWidth: Use 2 (not 1) spaces for indentation. create(:shipping_method_with, :pickup, name: "delivery", ^ spec/system/admin/orders_spec.rb:44:3: C: [Corrected] Layout/IndentationWidth: Use 2 (not 0) spaces for indentation. create(:shipping_method_with, :pickup, name: "delivery", spec/system/admin/orders_spec.rb:45:45: C: [Corrected] Layout/BlockEndNewline: Expression at 45, 45 should be on its own line. distributors: [distributor4, distributor5]) } ^ spec/system/admin/orders_spec.rb:46:1: C: [Corrected] Layout/BlockAlignment: } at 46, 0 is not aligned with let!(:shipping_method2) { at 43, 2. } ^ 1478 files inspected, 16 offenses detected, 16 offenses corrected --- .rubocop_todo.yml | 14 -------------- .../enterprise_fee_calculator_spec.rb | 9 ++++++--- spec/system/admin/orders_spec.rb | 5 +++-- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2c30eb3586..008941088f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -16,13 +16,6 @@ Gemspec/RequiredRubyVersion: - 'engines/order_management/order_management.gemspec' - 'engines/web/web.gemspec' -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -Layout/BlockEndNewline: - Exclude: - - 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb' - - 'spec/system/admin/orders_spec.rb' - # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). Layout/ClosingParenthesisIndentation: @@ -93,13 +86,6 @@ Layout/IndentationConsistency: - 'spec/system/admin/order_cycles/simple_spec.rb' - 'spec/system/admin/product_import_spec.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Width, AllowedPatterns. -Layout/IndentationWidth: - Exclude: - - 'spec/services/products_renderer_spec.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. diff --git a/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb b/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb index 7812a2086e..d5b77792bc 100644 --- a/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb +++ b/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb @@ -124,11 +124,14 @@ module OpenFoodNetwork let!(:ef_admin) { create(:enterprise_fee, fee_type: 'admin', amount: 1.23, name: "Admin") } let!(:ef_sales) { create(:enterprise_fee, fee_type: 'sales', amount: 4.56, name: "Sales") } let!(:ef_packing) { - create(:enterprise_fee, fee_type: 'packing', amount: 7.89, name: "Packing") } + create(:enterprise_fee, fee_type: 'packing', amount: 7.89, name: "Packing") + } let!(:ef_transport) { - create(:enterprise_fee, fee_type: 'transport', amount: 0.12, name: "Transport") } + create(:enterprise_fee, fee_type: 'transport', amount: 0.12, name: "Transport") + } let!(:ef_fundraising) { - create(:enterprise_fee, fee_type: 'fundraising', amount: 3.45, name: "Fundraising") } + create(:enterprise_fee, fee_type: 'fundraising', amount: 3.45, name: "Fundraising") + } let!(:exchange) { create(:exchange, order_cycle: order_cycle, sender: coordinator, receiver: distributor, incoming: false, diff --git a/spec/system/admin/orders_spec.rb b/spec/system/admin/orders_spec.rb index 3ce0295b36..064d7c2d1e 100644 --- a/spec/system/admin/orders_spec.rb +++ b/spec/system/admin/orders_spec.rb @@ -41,8 +41,9 @@ describe ' distributors: [distributor, distributor2, distributor3]) } let!(:shipping_method2) { - create(:shipping_method_with, :pickup, name: "delivery", -distributors: [distributor4, distributor5]) } + create(:shipping_method_with, :pickup, name: "delivery", + distributors: [distributor4, distributor5]) + } let(:order_cycle) do create(:simple_order_cycle, name: 'One', distributors: [distributor, distributor2, distributor3, distributor4], From 159a0d391c26fe775e2d258f200e9488cbeb6544 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 20 Jul 2023 13:56:13 +1000 Subject: [PATCH 06/11] Safely autocorrect Layout/ClosingParenthesisIndentation Inspecting 1478 files ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C........................................................................... Offenses: spec/system/admin/orders_spec.rb:486:9: C: [Corrected] Layout/ClosingParenthesisIndentation: Align ) with (. ).to be_checked ^ spec/system/admin/orders_spec.rb:494:9: C: [Corrected] Layout/ClosingParenthesisIndentation: Align ) with (. ).to_not be_checked ^ 1478 files inspected, 2 offenses detected, 2 offenses corrected --- .rubocop_todo.yml | 6 ------ spec/system/admin/orders_spec.rb | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 008941088f..f2d35ff2d9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -16,12 +16,6 @@ Gemspec/RequiredRubyVersion: - 'engines/order_management/order_management.gemspec' - 'engines/web/web.gemspec' -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Layout/ClosingParenthesisIndentation: - Exclude: - - 'spec/system/admin/orders_spec.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Layout/EmptyLines: diff --git a/spec/system/admin/orders_spec.rb b/spec/system/admin/orders_spec.rb index 064d7c2d1e..763e453264 100644 --- a/spec/system/admin/orders_spec.rb +++ b/spec/system/admin/orders_spec.rb @@ -483,7 +483,7 @@ describe ' page.find("#listing_orders thead th:first-child input[type=checkbox]").click expect(page.find( "#listing_orders tbody tr td:first-child input[type=checkbox]") - ).to be_checked + ).to be_checked # enables print invoices button page.find("span.icon-reorder", text: "ACTIONS").click expect(page).to have_content "Print Invoices" @@ -491,7 +491,7 @@ describe ' page.find("#listing_orders thead th:first-child input[type=checkbox]").trigger("click") expect(page.find( "#listing_orders tbody tr td:first-child input[type=checkbox]") - ).to_not be_checked + ).to_not be_checked # disables print invoices button page.find("span.icon-reorder", text: "ACTIONS").click expect(page).to_not have_content "Print Invoices" From 6fa9165cc2d9c1cb2b3d6770e93818deceaab1f8 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 20 Jul 2023 13:58:00 +1000 Subject: [PATCH 07/11] Safely autocorrect Layout/EmptyLines Inspecting 1478 files ..............................................................................................................................................................................................................................................................................................................................................C....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... Offenses: app/models/spree/payment.rb:100:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected. 1478 files inspected, 1 offense detected, 1 offense corrected --- .rubocop_todo.yml | 6 ------ app/models/spree/payment.rb | 1 - 2 files changed, 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f2d35ff2d9..cab3d7c28c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -16,12 +16,6 @@ Gemspec/RequiredRubyVersion: - 'engines/order_management/order_management.gemspec' - 'engines/web/web.gemspec' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLines: - Exclude: - - 'app/models/spree/payment.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. diff --git a/app/models/spree/payment.rb b/app/models/spree/payment.rb index df571004cb..8b4baeac05 100644 --- a/app/models/spree/payment.rb +++ b/app/models/spree/payment.rb @@ -97,7 +97,6 @@ module Spree transition from: [:void], to: :checkout end - after_transition to: :completed, do: :set_captured_at end From bc330b69a53fcd75b3c4d29202f9ace50c5e859a Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 20 Jul 2023 13:59:53 +1000 Subject: [PATCH 08/11] Safely autocorrect Layout/EmptyLinesAroundBlockBody Inspecting 1478 files ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C............................................................................... Offenses: spec/system/admin/order_cycles/list_spec.rb:191:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body end. 1478 files inspected, 1 offense detected, 1 offense corrected --- .rubocop_todo.yml | 8 -------- spec/system/admin/order_cycles/list_spec.rb | 1 - 2 files changed, 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index cab3d7c28c..d8055acb0c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -16,14 +16,6 @@ Gemspec/RequiredRubyVersion: - 'engines/order_management/order_management.gemspec' - 'engines/web/web.gemspec' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, no_empty_lines -Layout/EmptyLinesAroundBlockBody: - Exclude: - - 'spec/system/admin/order_cycles/list_spec.rb' - # Offense count: 3 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. diff --git a/spec/system/admin/order_cycles/list_spec.rb b/spec/system/admin/order_cycles/list_spec.rb index d69bc53fe8..1f52ca973a 100644 --- a/spec/system/admin/order_cycles/list_spec.rb +++ b/spec/system/admin/order_cycles/list_spec.rb @@ -188,7 +188,6 @@ describe ' expect(find('input.datetimepicker', match: :first).value).to eq test_value.to_datetime.strftime("%Y-%m-%d %H:%M") end - end end end From 68592003390dc0ba920ee717c71c1b385a22426e Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 20 Jul 2023 14:01:44 +1000 Subject: [PATCH 09/11] Safely autocorrect Layout/ExtraSpacing Inspecting 1478 files ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.......................................................................................................................................................................................................................C......................................................................................................................................................................................................C...................... Offenses: spec/lib/open_food_network/property_merge_spec.rb:22:57: C: [Corrected] Layout/ExtraSpacing: Unnecessary spacing detected. let(:product_property) { create(:product_property, property: property) } ^ spec/services/cart_service_spec.rb:276:58: C: [Corrected] Layout/ExtraSpacing: Unnecessary spacing detected. cart_service.instance_variable_set :@order_cycle, double(:order_cycle) ^ spec/system/consumer/shops_spec.rb:78:46: C: [Corrected] Layout/ExtraSpacing: Unnecessary spacing detected. expect(page).to have_no_selector 'hub', text: d2.name ^^ 1478 files inspected, 3 offenses detected, 3 offenses corrected --- .rubocop_todo.yml | 9 --------- spec/lib/open_food_network/property_merge_spec.rb | 2 +- spec/services/cart_service_spec.rb | 2 +- spec/system/consumer/shops_spec.rb | 2 +- 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d8055acb0c..67232cba0c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -16,15 +16,6 @@ Gemspec/RequiredRubyVersion: - 'engines/order_management/order_management.gemspec' - 'engines/web/web.gemspec' -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. -Layout/ExtraSpacing: - Exclude: - - 'spec/lib/open_food_network/property_merge_spec.rb' - - 'spec/services/cart_service_spec.rb' - - 'spec/system/consumer/shops_spec.rb' - # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. diff --git a/spec/lib/open_food_network/property_merge_spec.rb b/spec/lib/open_food_network/property_merge_spec.rb index cd139188be..6b338c7b74 100644 --- a/spec/lib/open_food_network/property_merge_spec.rb +++ b/spec/lib/open_food_network/property_merge_spec.rb @@ -19,7 +19,7 @@ module OpenFoodNetwork end describe "merging ProducerProperties and Spree::ProductProperties" do - let(:product_property) { create(:product_property, property: property) } + let(:product_property) { create(:product_property, property: property) } let(:duplicate_product_property) { create(:producer_property, property: duplicate_property) } let(:producer_property) { create(:producer_property, property: different_property) } diff --git a/spec/services/cart_service_spec.rb b/spec/services/cart_service_spec.rb index 05f574ba89..5b314d20f8 100644 --- a/spec/services/cart_service_spec.rb +++ b/spec/services/cart_service_spec.rb @@ -273,7 +273,7 @@ describe CartService do end it "returns true when order cycle is provided" do - cart_service.instance_variable_set :@order_cycle, double(:order_cycle) + cart_service.instance_variable_set :@order_cycle, double(:order_cycle) expect(cart_service.send(:check_order_cycle_provided)).to be true end end diff --git a/spec/system/consumer/shops_spec.rb b/spec/system/consumer/shops_spec.rb index 2bae3a92ed..a807c078d8 100644 --- a/spec/system/consumer/shops_spec.rb +++ b/spec/system/consumer/shops_spec.rb @@ -75,7 +75,7 @@ describe 'Shops' do it "does not show hubs that are not in an order cycle" do expect(page).to have_no_selector 'hub.inactive' - expect(page).to have_no_selector 'hub', text: d2.name + expect(page).to have_no_selector 'hub', text: d2.name end it "does not show profiles" do From aa124511def407c01ab3ef1098f60891f874bf8a Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 20 Jul 2023 14:03:31 +1000 Subject: [PATCH 10/11] Safely autocorrect Layout/FirstArgumentIndentation Inspecting 1478 files ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C........................................................................... Offenses: spec/system/admin/orders_spec.rb:485:11: C: [Corrected] Layout/FirstArgumentIndentation: Indent the first argument one step more than page.find(. "#listing_orders tbody tr td:first-child input[type=checkbox]") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/system/admin/orders_spec.rb:493:11: C: [Corrected] Layout/FirstArgumentIndentation: Indent the first argument one step more than page.find(. "#listing_orders tbody tr td:first-child input[type=checkbox]") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1478 files inspected, 2 offenses detected, 2 offenses corrected --- .rubocop_todo.yml | 8 -------- spec/system/admin/orders_spec.rb | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 67232cba0c..16b61e87e7 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -16,14 +16,6 @@ Gemspec/RequiredRubyVersion: - 'engines/order_management/order_management.gemspec' - 'engines/web/web.gemspec' -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses -Layout/FirstArgumentIndentation: - Exclude: - - 'spec/system/admin/orders_spec.rb' - # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. diff --git a/spec/system/admin/orders_spec.rb b/spec/system/admin/orders_spec.rb index 763e453264..cf6f31cd29 100644 --- a/spec/system/admin/orders_spec.rb +++ b/spec/system/admin/orders_spec.rb @@ -482,7 +482,7 @@ describe ' # select all orders page.find("#listing_orders thead th:first-child input[type=checkbox]").click expect(page.find( - "#listing_orders tbody tr td:first-child input[type=checkbox]") + "#listing_orders tbody tr td:first-child input[type=checkbox]") ).to be_checked # enables print invoices button page.find("span.icon-reorder", text: "ACTIONS").click @@ -490,7 +490,7 @@ describe ' # unselect all orders page.find("#listing_orders thead th:first-child input[type=checkbox]").trigger("click") expect(page.find( - "#listing_orders tbody tr td:first-child input[type=checkbox]") + "#listing_orders tbody tr td:first-child input[type=checkbox]") ).to_not be_checked # disables print invoices button page.find("span.icon-reorder", text: "ACTIONS").click From 19ee2b50c2eb47986061613581024eb602de3e29 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 20 Jul 2023 14:05:16 +1000 Subject: [PATCH 11/11] Safely autocorrect Layout/FirstHashElementIndentation Inspecting 1478 files ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.................................................................................................................................................................................. Offenses: spec/services/products_renderer_spec.rb:73:11: C: [Corrected] Layout/FirstHashElementIndentation: Use 2 spaces for indentation in a hash, relative to the first position after the preceding left parenthesis. "#{[:name, :meta_keywords, :variants_display_as, ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/services/products_renderer_spec.rb:76:9: C: [Corrected] Layout/FirstHashElementIndentation: Indent the right brace the same as the first position after the preceding left parenthesis. } }) ^ 1478 files inspected, 2 offenses detected, 2 offenses corrected --- .rubocop_todo.yml | 8 -------- spec/services/products_renderer_spec.rb | 8 ++++---- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 16b61e87e7..dd41add2d0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -16,14 +16,6 @@ Gemspec/RequiredRubyVersion: - 'engines/order_management/order_management.gemspec' - 'engines/web/web.gemspec' -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_braces -Layout/FirstHashElementIndentation: - Exclude: - - 'spec/services/products_renderer_spec.rb' - # Offense count: 9 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. diff --git a/spec/services/products_renderer_spec.rb b/spec/services/products_renderer_spec.rb index 78ec2aae8e..9cbf7dc3f5 100644 --- a/spec/services/products_renderer_spec.rb +++ b/spec/services/products_renderer_spec.rb @@ -70,10 +70,10 @@ describe ProductsRenderer do it "filters products by name_or_meta_keywords_or_variants_display_as_or_" \ "variants_display_name_or_supplier_name_cont" do products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, { q: { - "#{[:name, :meta_keywords, :variants_display_as, - :variants_display_name, :supplier_name] - .join('_or_')}_cont": "apples", - } }) + "#{[:name, :meta_keywords, :variants_display_as, + :variants_display_name, :supplier_name] + .join('_or_')}_cont": "apples", + } }) products = products_renderer.send(:products) expect(products).to eq([product_apples]) end