Shopify/active_merchant

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

Summary

Maintainability
D
2 days
Test Coverage

Class DeepstackGateway has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

    class DeepstackGateway < Gateway
      self.test_url = 'https://api.sandbox.deepstack.io'
      self.live_url = 'https://api.deepstack.io'

      self.supported_countries = ['US']
Severity: Minor
Found in lib/active_merchant/billing/gateways/deepstack.rb - About 4 hrs to fix

    File deepstack.rb has 327 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module ActiveMerchant #:nodoc:
      module Billing #:nodoc:
        class DeepstackGateway < Gateway
          self.test_url = 'https://api.sandbox.deepstack.io'
          self.live_url = 'https://api.deepstack.io'
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/deepstack.rb - About 3 hrs to fix

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

            def add_address(post, creditcard, options)
              return post unless options.key?(:address) || options.key?(:billing_address)
      
              billing_address = options[:address] || options[:billing_address]
              post[:source] ||= {}
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/deepstack.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_address_payment_instrument has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_address_payment_instrument(post, creditcard, options)
              return post unless options.key?(:address) || options.key?(:billing_address)
      
              billing_address = options[:address] || options[:billing_address]
              post[:source] = {} unless post.key?(:payment_instrument)
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/deepstack.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_shipping has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_shipping(post, options = {})
              return post unless options.key?(:shipping_address)
      
              shipping = options[:shipping_address]
              post[:meta][:shipping_info] = {}
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/deepstack.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 commit has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def commit(action, parameters, method = 'POST')
              url = (test? ? test_url : live_url)
              if no_hmac(action)
                request_headers = headers.merge(create_basic(parameters, action))
              else
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/deepstack.rb - About 1 hr to fix

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

              def add_customer_data(post, options)
                post[:meta] ||= {}
        
                add_shipping(post, options) if options.key?(:shipping_address)
                post[:meta][:client_customer_id] = options[:customer] if options[:customer]
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/deepstack.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

        Avoid too many return statements within this method.
        Open

                  return base + 'vault/payment-instrument/token'
        Severity: Major
        Found in lib/active_merchant/billing/gateways/deepstack.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                    return base + 'vault/token'
          Severity: Major
          Found in lib/active_merchant/billing/gateways/deepstack.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                      return base + 'payments/refund'
            Severity: Major
            Found in lib/active_merchant/billing/gateways/deepstack.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                        return base + 'noaction'
              Severity: Major
              Found in lib/active_merchant/billing/gateways/deepstack.rb - About 30 mins to fix

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

                          Response.new(
                            success_from(response),
                            message_from(response),
                            response,
                            authorization: authorization_from(response),
                Severity: Major
                Found in lib/active_merchant/billing/gateways/deepstack.rb and 4 other locations - About 25 mins to fix
                lib/active_merchant/billing/gateways/card_connect.rb on lines 300..309
                lib/active_merchant/billing/gateways/ct_payment.rb on lines 210..219
                lib/active_merchant/billing/gateways/decidir_plus.rb on lines 254..263
                lib/active_merchant/billing/gateways/mit.rb on lines 232..241

                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 30.

                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