diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b3a7f2c476..13ca462ab1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -540,13 +540,6 @@ Style/ArrayIntersect: - 'lib/open_food_network/tag_rule_applicator.rb' - 'spec/support/matchers/select2_matchers.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowOnConstant, AllowOnSelfClass. -Style/CaseEquality: - Exclude: - - 'spec/models/spree/payment_spec.rb' - # Offense count: 23 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. @@ -576,24 +569,6 @@ Style/ClassAndModuleChildren: - 'lib/open_food_network/locking.rb' - 'spec/models/spree/payment_method_spec.rb' -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: always, always_true, never -Style/FrozenStringLiteralComment: - Exclude: - - '.simplecov' - -# Offense count: 6 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/GlobalStdStream: - Exclude: - - 'lib/tasks/data.rake' - - 'lib/tasks/missing_payments.rake' - - 'lib/tasks/sample_data/logging.rb' - - 'lib/tasks/subscriptions/debug.rake' - - 'lib/tasks/subscriptions/test.rake' - # Offense count: 10 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowSplatArgument. @@ -684,21 +659,6 @@ Style/OptionalBooleanParameter: - 'lib/spree/core/controller_helpers/order.rb' - 'spec/support/request/web_helper.rb' -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: short, verbose -Style/PreferredHashMethods: - Exclude: - - 'app/controllers/api/v0/shipments_controller.rb' - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AutoCorrect, AllowComments. -Style/RedundantInitialize: - Exclude: - - 'spec/models/spree/gateway_spec.rb' - # Offense count: 19 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedMethods, AllowedPatterns. @@ -707,11 +667,3 @@ Style/ReturnNilInPredicateMethodDefinition: - 'app/models/order_cycle.rb' - 'app/serializers/api/admin/customer_serializer.rb' - 'engines/order_management/app/services/order_management/subscriptions/validator.rb' - -# Offense count: 3 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/SlicingWithRange: - Exclude: - - 'app/helpers/spree/admin/navigation_helper.rb' - - 'app/services/embedded_page_service.rb' - - 'engines/order_management/app/services/order_management/subscriptions/validator.rb' diff --git a/.simplecov b/.simplecov index 8cf02c6b54..66573a094d 100755 --- a/.simplecov +++ b/.simplecov @@ -1,4 +1,5 @@ #!/bin/env ruby +# frozen_string_literal: true SimpleCov.start 'rails' do add_filter '/bin/' diff --git a/app/controllers/api/v0/shipments_controller.rb b/app/controllers/api/v0/shipments_controller.rb index 1580e1f89f..afaea6a5b2 100644 --- a/app/controllers/api/v0/shipments_controller.rb +++ b/app/controllers/api/v0/shipments_controller.rb @@ -117,7 +117,7 @@ module Api end def shipment_params - return {} unless params.has_key? :shipment + return {} unless params.key? :shipment params.require(:shipment).permit(:tracking, :selected_shipping_rate_id) end diff --git a/app/helpers/spree/admin/navigation_helper.rb b/app/helpers/spree/admin/navigation_helper.rb index d39ac5b3cc..7b408e5ef5 100644 --- a/app/helpers/spree/admin/navigation_helper.rb +++ b/app/helpers/spree/admin/navigation_helper.rb @@ -122,7 +122,7 @@ module Spree end else if html_options['data-update'].nil? && html_options[:remote] - object_name, action = url.split('/')[-2..-1] + object_name, action = url.split('/')[-2..] html_options['data-update'] = [action, object_name.singularize].join('_') end diff --git a/app/services/embedded_page_service.rb b/app/services/embedded_page_service.rb index 52fc4b98c4..6e979c9722 100644 --- a/app/services/embedded_page_service.rb +++ b/app/services/embedded_page_service.rb @@ -81,7 +81,7 @@ class EmbeddedPageService def current_referer_without_www return unless current_referer - current_referer.start_with?('www.') ? current_referer[4..-1] : current_referer + current_referer.start_with?('www.') ? current_referer[4..] : current_referer end def set_embedded_layout diff --git a/engines/order_management/app/services/order_management/subscriptions/validator.rb b/engines/order_management/app/services/order_management/subscriptions/validator.rb index 4808d7353c..1dc04bfd5d 100644 --- a/engines/order_management/app/services/order_management/subscriptions/validator.rb +++ b/engines/order_management/app/services/order_management/subscriptions/validator.rb @@ -128,7 +128,7 @@ module OrderManagement end def build_msg_from(key, msg) - return msg[1..-1] if msg.starts_with?("^") + return msg[1..] if msg.starts_with?("^") errors.full_message(key, msg) end diff --git a/lib/tasks/data.rake b/lib/tasks/data.rake index bb26f748b1..8f8a2b0183 100644 --- a/lib/tasks/data.rake +++ b/lib/tasks/data.rake @@ -78,11 +78,11 @@ namespace :ofn do # Ask how many months back we want to search for puts "This task will search order cycle edited within (n) months of today's date.\n" \ "Please enter a value for (n), or hit ENTER to use the default of three (3) months." - input = check_default(STDIN.gets.chomp) + input = check_default($stdin.gets.chomp) while !is_integer?(input) puts "'#{input}' is not an integer. Please enter an integer." - input = check_default(STDIN.gets.chomp) + input = check_default($stdin.gets.chomp) end Integer(input) diff --git a/lib/tasks/missing_payments.rake b/lib/tasks/missing_payments.rake index c822b62ee4..9f0982f82d 100644 --- a/lib/tasks/missing_payments.rake +++ b/lib/tasks/missing_payments.rake @@ -44,7 +44,7 @@ namespace :ofn do details = Psych.load(entry.details) out << row(details, details.params) rescue StandardError - Logger.new(STDERR).warn(entry) + Logger.new($stderr).warn(entry) end def headers diff --git a/lib/tasks/sample_data/logging.rb b/lib/tasks/sample_data/logging.rb index ad85624092..9204b664be 100644 --- a/lib/tasks/sample_data/logging.rb +++ b/lib/tasks/sample_data/logging.rb @@ -4,7 +4,7 @@ module Logging private def log(message) - @logger ||= ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) + @logger ||= ActiveSupport::TaggedLogging.new(Logger.new($stdout)) @logger.tagged("ofn:sample_data") { @logger.info(message) } end end diff --git a/lib/tasks/subscriptions/debug.rake b/lib/tasks/subscriptions/debug.rake index 750bfb4d73..bd641ce11f 100644 --- a/lib/tasks/subscriptions/debug.rake +++ b/lib/tasks/subscriptions/debug.rake @@ -54,7 +54,7 @@ namespace :ofn do def request_order_cycle_id puts "Please input Order Cycle ID to debug" - input = STDIN.gets.chomp + input = $stdin.gets.chomp exit if input.blank? || !Integer(input) Integer(input) end diff --git a/lib/tasks/subscriptions/test.rake b/lib/tasks/subscriptions/test.rake index ff6317b841..c4349f1b7b 100644 --- a/lib/tasks/subscriptions/test.rake +++ b/lib/tasks/subscriptions/test.rake @@ -62,7 +62,7 @@ namespace :ofn do def request_order_cycle_id puts "Please input Order Cycle ID to reset" - input = STDIN.gets.chomp + input = $stdin.gets.chomp exit if input.blank? || !Integer(input) Integer(input) end diff --git a/spec/models/spree/gateway_spec.rb b/spec/models/spree/gateway_spec.rb index 23b0b97d96..b1e0d65205 100644 --- a/spec/models/spree/gateway_spec.rb +++ b/spec/models/spree/gateway_spec.rb @@ -7,7 +7,7 @@ RSpec.describe Spree::Gateway do Class.new(Spree::Gateway) do def provider_class Class.new do - def initialize(options = {}); end + def initialize(*); end def imaginary_method; end end diff --git a/spec/models/spree/payment_spec.rb b/spec/models/spree/payment_spec.rb index e22e064b60..1389d62d1a 100644 --- a/spec/models/spree/payment_spec.rb +++ b/spec/models/spree/payment_spec.rb @@ -868,7 +868,7 @@ RSpec.describe Spree::Payment do let(:payment) { build_stubbed(:payment) } it "returns the parameter amount when given" do - expect(payment.__send__(:calculate_refund_amount, 123)).to be === 123.0 + expect(payment.__send__(:calculate_refund_amount, 123)).to eq(123) end it "refunds up to the value of the payment when the outstanding balance is larger" do