Shopify/active_merchant

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

Summary

Maintainability
D
2 days
Test Coverage

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

    class DecidirPlusGateway < Gateway
      self.test_url = 'https://developers.decidir.com/api/v2'
      self.live_url = 'https://live.decidir.com/api/v2'

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

    File decidir_plus.rb has 280 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module ActiveMerchant #:nodoc:
      module Billing #:nodoc:
        class DecidirPlusGateway < Gateway
          self.test_url = 'https://developers.decidir.com/api/v2'
          self.live_url = 'https://live.decidir.com/api/v2'
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/decidir_plus.rb - About 2 hrs to fix

      Method add_aggregate_data has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_aggregate_data(post, options)
              aggregate_data = {}
              data = options[:aggregate_data]
              aggregate_data[:indicator] = data[:indicator] if data[:indicator]
              aggregate_data[:identification_number] = data[:identification_number] if data[:identification_number]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/decidir_plus.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 error_code_from has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def error_code_from(response)
              return if success_from(response)
      
              error_code = nil
              if error = response.dig('status_details', 'error')
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/decidir_plus.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_payment has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_payment(post, payment, options = {})
              if payment.is_a?(String)
                token, bin = payment.split('|')
                post[:token] = token
                post[:bin] = bin
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/decidir_plus.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_payment_method_id has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def add_payment_method_id(options)
              return options[:payment_method_id].to_i if options[:payment_method_id]
      
              if options[:debit]
                case options[:card_brand]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/decidir_plus.rb - About 1 hr to fix

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

              def add_payment_method_id(options)
                return options[:payment_method_id].to_i if options[:payment_method_id]
        
                if options[:debit]
                  case options[:card_brand]
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/decidir_plus.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_fraud_detection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def add_fraud_detection(post, options)
                return unless fraud_detection = options[:fraud_detection]
        
                {}.tap do |hsh|
                  hsh[:send_to_cs] = fraud_detection[:send_to_cs] == 'true' # true/false
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/decidir_plus.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

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

              def add_aggregate_data(post, options)
                aggregate_data = {}
                data = options[:aggregate_data]
                aggregate_data[:indicator] = data[:indicator] if data[:indicator]
                aggregate_data[:identification_number] = data[:identification_number] if data[:identification_number]
        Severity: Major
        Found in lib/active_merchant/billing/gateways/decidir_plus.rb and 1 other location - About 5 hrs to fix
        lib/active_merchant/billing/gateways/decidir.rb on lines 221..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 182.

        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

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

                  error = response.dig('error')
                  validation_errors = error.dig('validation_errors', 0)
                  code = validation_errors['code'] if validation_errors && validation_errors['code']
                  param = validation_errors['param'] if validation_errors && validation_errors['param']
                  error_code = "#{error['error_type']} | #{code} | #{param}" if error['error_type']
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/decidir_plus.rb and 1 other location - About 55 mins to fix
        lib/active_merchant/billing/gateways/decidir.rb on lines 369..373

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

        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

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

              def add_sub_payments(post, options)
                # sub_payments field is required for purchase transactions, even if empty
                post[:sub_payments] = []
        
                return unless sub_payments = options[:sub_payments]
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/decidir_plus.rb and 1 other location - About 40 mins to fix
        lib/active_merchant/billing/gateways/decidir.rb on lines 244..256

        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

        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/decidir_plus.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/deepstack.rb on lines 233..242
        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