Safely autocorrect Style/RedundantReturn

Inspecting 1513 files
.........................................................................................................................................................................................................................................................................................................C......................................................C............................................................................................................................................................................................................................................................................................................................................................................................................................................C.........................................................C.......C.........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

app/models/product_import/entry_validator.rb:200:7: C: [Corrected] Style/RedundantReturn: Redundant return detected.
      return true unless Float(value, exception: false).nil?
      ^^^^^^
app/models/spree/stock/availability_validator.rb:30:9: C: [Corrected] Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.
        return line_item.target_shipment if line_item.target_shipment
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/stock/availability_validator.rb:31:9: C: [Corrected] Style/RedundantReturn: Redundant return detected.
        return line_item.order.shipments.first if line_item.order&.shipments&.any?
        ^^^^^^
lib/reporting/reports/enterprise_fee_summary/summarizer.rb:41:11: C: [Corrected] Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.
          return DataRepresentations::IncomingExchangeLineItemFee if for_incoming_exchange?
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/summarizer.rb:42:11: C: [Corrected] Style/RedundantReturn: Redundant return detected.
          return DataRepresentations::OutgoingExchangeLineItemFee if for_outgoing_exchange?
          ^^^^^^
lib/stripe/authorize_response_patcher.rb:31:7: C: [Corrected] Style/RedundantReturn: Redundant return detected.
      return url if url.match(%r{https?://\S+}) && url.include?("stripe.com")
      ^^^^^^
lib/tasks/data.rake:99:7: C: [Corrected] Style/RedundantReturn: Redundant return detected.
      return true if Integer(value)
      ^^^^^^

1513 files inspected, 7 offenses detected, 7 offenses corrected
This commit is contained in:
Neal Chambers
2023-11-17 09:00:50 +09:00
parent 85fef7ac4b
commit edbf4c15a9
6 changed files with 7 additions and 16 deletions

View File

@@ -937,17 +937,6 @@ Style/RedundantInterpolation:
- 'lib/tasks/karma.rake'
- 'spec/base_spec_helper.rb'
# Offense count: 5
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
Exclude:
- 'app/models/product_import/entry_validator.rb'
- 'app/models/spree/stock/availability_validator.rb'
- 'lib/reporting/reports/enterprise_fee_summary/summarizer.rb'
- 'lib/stripe/authorize_response_patcher.rb'
- 'lib/tasks/data.rake'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantSelf:

View File

@@ -197,7 +197,7 @@ module ProductImport
end
def is_numeric(value)
return true unless Float(value, exception: false).nil?
true unless Float(value, exception: false).nil?
end
def price_validation(entry)

View File

@@ -28,7 +28,8 @@ module Spree
def line_item_shipment(line_item)
return line_item.target_shipment if line_item.target_shipment
return line_item.order.shipments.first if line_item.order&.shipments&.any?
line_item.order.shipments.first if line_item.order&.shipments&.any?
end
# Overrides Spree v2.0.4 validate method version to:

View File

@@ -39,7 +39,8 @@ module Reporting
return DataRepresentations::ExchangeOrderFee if for_order_adjustment_source?
return unless for_line_item_adjustment_source?
return DataRepresentations::IncomingExchangeLineItemFee if for_incoming_exchange?
return DataRepresentations::OutgoingExchangeLineItemFee if for_outgoing_exchange?
DataRepresentations::OutgoingExchangeLineItemFee if for_outgoing_exchange?
end
def for_payment_method?

View File

@@ -28,7 +28,7 @@ module Stripe
return unless %w(authorize_with_url redirect_to_url).include?(next_action_type)
url = next_action[next_action_type]["url"]
return url if url.match(%r{https?://\S+}) && url.include?("stripe.com")
url if url.match(%r{https?://\S+}) && url.include?("stripe.com")
end
# This field is used because the Spree code recognizes and stores it

View File

@@ -96,7 +96,7 @@ namespace :ofn do
end
def is_integer?(value)
return true if Integer(value)
true if Integer(value)
rescue StandardError
false
end