mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-30 21:27:17 +00:00
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
41 lines
1.2 KiB
Ruby
41 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
# This class patches the Stripe API response to the authorize action
|
|
# It copies the authorization URL to a field that is recognized and persisted by Spree payments
|
|
module Stripe
|
|
class AuthorizeResponsePatcher
|
|
def initialize(response)
|
|
@response = response
|
|
end
|
|
|
|
def call!
|
|
if (url = url_for_authorization(@response)) && field_to_patch(@response).present?
|
|
field_to_patch(@response)['message'] = url
|
|
end
|
|
|
|
@response
|
|
end
|
|
|
|
private
|
|
|
|
def url_for_authorization(response)
|
|
return unless %w(requires_source_action requires_action).include?(response.params["status"])
|
|
|
|
next_action = response.params["next_source_action"] || response.params["next_action"]
|
|
return if next_action.blank?
|
|
|
|
next_action_type = next_action["type"]
|
|
return unless %w(authorize_with_url redirect_to_url).include?(next_action_type)
|
|
|
|
url = next_action[next_action_type]["url"]
|
|
url if url.match(%r{https?://\S+}) && url.include?("stripe.com")
|
|
end
|
|
|
|
# This field is used because the Spree code recognizes and stores it
|
|
# This data is then used in Checkout::StripeRedirect
|
|
def field_to_patch(response)
|
|
response.cvv_result
|
|
end
|
|
end
|
|
end
|