Merge pull request #13231 from chitty/more-rubocop-style-corrections

Correct rubocop Style/* offenses
This commit is contained in:
Gaetan Craig-Riou
2025-03-31 10:49:20 +11:00
committed by GitHub
13 changed files with 13 additions and 60 deletions

View File

@@ -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'

View File

@@ -1,4 +1,5 @@
#!/bin/env ruby
# frozen_string_literal: true
SimpleCov.start 'rails' do
add_filter '/bin/'

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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