Shopify/active_merchant

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

Summary

Maintainability
D
1 day
Test Coverage

Class DLocalGateway has 36 methods (exceeds 20 allowed). Consider refactoring.
Open

    class DLocalGateway < Gateway
      self.test_url = 'https://sandbox.dlocal.com'
      self.live_url = 'https://api.dlocal.com'

      self.supported_countries = %w[AR BD BO BR CL CM CN CO CR DO EC EG GH GT IN ID JP KE MY MX MA NG PA PY PE PH SN SV TH TR TZ UG UY VN ZA]
Severity: Minor
Found in lib/active_merchant/billing/gateways/d_local.rb - About 4 hrs to fix

    File d_local.rb has 285 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module ActiveMerchant #:nodoc:
      module Billing #:nodoc:
        class DLocalGateway < Gateway
          self.test_url = 'https://sandbox.dlocal.com'
          self.live_url = 'https://api.dlocal.com'
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/d_local.rb - About 2 hrs to fix

      Method add_card has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_card(post, card, action, options = {})
              post[:card] = {}
              if card.is_a?(NetworkTokenizationCreditCard)
                post[:card][:network_token] = card.number
                post[:card][:cryptogram] = card.payment_cryptogram
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/d_local.rb - About 2 hrs 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_card has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def add_card(post, card, action, options = {})
              post[:card] = {}
              if card.is_a?(NetworkTokenizationCreditCard)
                post[:card][:network_token] = card.number
                post[:card][:cryptogram] = card.payment_cryptogram
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/d_local.rb - About 1 hr to fix

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

              def add_payer(post, card, options)
                address = options[:billing_address] || options[:address]
                post[:payer] = {}
                post[:payer][:name] = card.name
                post[:payer][:email] = options[:email] if options[:email]
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/d_local.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 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def add_address(post, card, options)
                return unless address = options[:billing_address] || options[:address]
        
                address_object = {}
                address_object[:state] = address[:state] if address[:state]
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/d_local.rb - About 45 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 validate_three_ds_params has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def validate_three_ds_params(three_ds)
                errors = {}
                supported_version = %w{1.0 2.0 2.1.0 2.2.0}.include?(three_ds[:three_dsecure_version])
                supported_enrollment = ['Y', 'N', 'U', nil].include?(three_ds[:enrollment_response])
                supported_auth_response = ['Y', 'N', 'U', nil].include?(three_ds[:authentication_response])
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/d_local.rb - About 45 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_auth_purchase_params has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def add_auth_purchase_params(post, money, card, action, options)
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/d_local.rb - About 35 mins to fix

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

                self.supported_countries = %w[AR BD BO BR CL CM CN CO CR DO EC EG GH GT IN ID JP KE MY MX MA NG PA PY PE PH SN SV TH TR TZ UG UY VN ZA]
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/d_local.rb and 1 other location - About 40 mins to fix
          lib/active_merchant/billing/gateways/clearhaus.rb on lines 7..8

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

          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