Shopify/active_merchant

View on GitHub
lib/active_merchant/billing/gateways/rapyd.rb

Summary

Maintainability
D
2 days
Test Coverage

Class RapydGateway has 48 methods (exceeds 20 allowed). Consider refactoring.
Open

    class RapydGateway < Gateway
      class_attribute :payment_redirect_test, :payment_redirect_live

      self.test_url = 'https://sandboxapi.rapyd.net/v1/'
      self.live_url = 'https://api.rapyd.net/v1/'
Severity: Minor
Found in lib/active_merchant/billing/gateways/rapyd.rb - About 6 hrs to fix

    File rapyd.rb has 339 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module ActiveMerchant #:nodoc:
      module Billing #:nodoc:
        class RapydGateway < Gateway
          class_attribute :payment_redirect_test, :payment_redirect_live
    
    
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/rapyd.rb - About 4 hrs to fix

      Method add_address has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_address(post, creditcard, options)
              return unless address = options[:billing_address]
      
              post[:address] = {}
              # name and line_1 are required at the gateway
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/rapyd.rb - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method add_customer_data has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_customer_data(post, payment, options, action = '')
              phone_number = options.dig(:billing_address, :phone) || options.dig(:billing_address, :phone_number)
              post[:phone_number] = phone_number.gsub(/\D/, '') unless phone_number.nil?
              post[:receipt_email] = options[:email] if payment.is_a?(String) && options[:customer_id].present? && !send_customer_object?(options)
      
      
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/rapyd.rb - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method address has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def address(options)
              return unless address = options[:billing_address]
      
              formatted_address = {}
      
      
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/rapyd.rb - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method url has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def url(action, url_override = nil)
              if url_override.to_s == 'payment_redirect' && action == 'payments'
                (self.test? ? self.payment_redirect_test : self.payment_redirect_live) + action.to_s
              else
                (self.test? ? self.test_url : self.live_url) + action.to_s
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/rapyd.rb - About 55 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method add_invoice has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_invoice(post, money, options)
              post[:amount] = money.zero? ? 0 : amount(money).to_f.to_s
              post[:currency] = (options[:currency] || currency(money))
              post[:merchant_reference_id] = options[:merchant_reference_id] || options[:order_id]
              post[:requested_currency] = options[:requested_currency] if options[:requested_currency].present?
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/rapyd.rb - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method customer_fields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def customer_fields(payment, options)
              return if options[:customer_id]
      
              customer_address = address(options)
              customer_data = {}
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/rapyd.rb - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method add_network_reference_id has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_network_reference_id(post, options)
              return unless (options[:stored_credential] && options[:stored_credential][:reason_type] == 'recurring') || options[:network_transaction_id]
      
              network_transaction_id = options[:network_transaction_id] || options[:stored_credential][:network_transaction_id]
              post[:payment_method][:fields][:network_reference_id] = network_transaction_id unless network_transaction_id&.empty?
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/rapyd.rb - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

            self.supported_countries = %w(CA CL CO DO SV PE PT VI AU HK IN ID JP MY NZ PH SG KR TW TH VN AD AT BE BA BG HR CY CZ DK EE FI FR GE DE GI GR GL HU IS IE IL IT LV LI LT LU MK MT MD MC ME NL GB NO PL RO RU SM SK SI ZA ES SE CH TR VA)
      Severity: Major
      Found in lib/active_merchant/billing/gateways/rapyd.rb and 2 other locations - About 1 hr to fix
      lib/active_merchant/billing/gateways/spreedly_core.rb on lines 12..15
      lib/active_merchant/billing/gateways/trexle.rb on lines 9..12

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 70.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      There are no issues that match your filters.

      Category
      Status