Shopify/active_merchant

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

Summary

Maintainability
D
2 days
Test Coverage

File iridium.rb has 431 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    # For more information on the Iridium Gateway please download the
    # documentation from their Merchant Management System.
    #
Severity: Minor
Found in lib/active_merchant/billing/gateways/iridium.rb - About 6 hrs to fix

    Method parse_element has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

          def parse_element(reply, node)
            case node.name
            when 'CrossReferenceTransactionResult'
              reply[:transaction_result] = {}
              node.attributes.each do |a, b|
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/iridium.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

    Class IridiumGateway has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class IridiumGateway < Gateway
          self.live_url = self.test_url = 'https://gw1.iridiumcorp.net/'
    
          # The countries the gateway supports merchants from as 2 digit ISO country codes
          self.supported_countries = %w[GB ES]
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/iridium.rb - About 2 hrs to fix

      Method parse_element has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def parse_element(reply, node)
              case node.name
              when 'CrossReferenceTransactionResult'
                reply[:transaction_result] = {}
                node.attributes.each do |a, b|
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/iridium.rb - About 1 hr to fix

        Method add_customerdetails has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def add_customerdetails(xml, creditcard, address, options, shipTo = false)
                xml.tag! 'CustomerDetails' do
                  if address
                    country_code = Country.find(address[:country]).code(:numeric) unless address[:country].blank?
                    xml.tag! 'BillingAddress' do
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/iridium.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_customerdetails has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def add_customerdetails(xml, creditcard, address, options, shipTo = false)
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/iridium.rb - About 35 mins to fix

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

                def parse(xml)
                  reply = {}
                  xml = REXML::Document.new(xml)
                  if (root = REXML::XPath.first(xml, '//CardDetailsTransactionResponse')) ||
                     (root = REXML::XPath.first(xml, '//CrossReferenceTransactionResponse'))
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/iridium.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 5 locations. Consider refactoring.
          Open

                  when 'CrossReferenceTransactionResult'
                    reply[:transaction_result] = {}
                    node.attributes.each do |a, b|
                      reply[:transaction_result][a.underscore.to_sym] = b
                    end
          Severity: Major
          Found in lib/active_merchant/billing/gateways/iridium.rb and 4 other locations - About 30 mins to fix
          lib/active_merchant/billing/gateways/iridium.rb on lines 436..441
          lib/active_merchant/billing/gateways/iridium.rb on lines 443..446
          lib/active_merchant/billing/gateways/iridium.rb on lines 447..450
          lib/active_merchant/billing/gateways/iridium.rb on lines 451..454

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

          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

                  when 'TransactionOutputData'
                    reply[:transaction_output_data] = {}
                    node.attributes.each { |a, b| reply[:transaction_output_data][a.underscore.to_sym] = b }
                    node.elements.each { |e| parse_element(reply[:transaction_output_data], e) } if node.has_elements?
          Severity: Major
          Found in lib/active_merchant/billing/gateways/iridium.rb and 4 other locations - About 30 mins to fix
          lib/active_merchant/billing/gateways/iridium.rb on lines 429..434
          lib/active_merchant/billing/gateways/iridium.rb on lines 436..441
          lib/active_merchant/billing/gateways/iridium.rb on lines 447..450
          lib/active_merchant/billing/gateways/iridium.rb on lines 451..454

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

          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

                  when 'GatewayEntryPoints'
                    reply[:gateway_entry_points] = {}
                    node.attributes.each { |a, b| reply[:gateway_entry_points][a.underscore.to_sym] = b }
                    node.elements.each { |e| parse_element(reply[:gateway_entry_points], e) } if node.has_elements?
          Severity: Major
          Found in lib/active_merchant/billing/gateways/iridium.rb and 4 other locations - About 30 mins to fix
          lib/active_merchant/billing/gateways/iridium.rb on lines 429..434
          lib/active_merchant/billing/gateways/iridium.rb on lines 436..441
          lib/active_merchant/billing/gateways/iridium.rb on lines 443..446
          lib/active_merchant/billing/gateways/iridium.rb on lines 447..450

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

          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

                  when 'CardDetailsTransactionResult'
                    reply[:transaction_result] = {}
                    node.attributes.each do |a, b|
                      reply[:transaction_result][a.underscore.to_sym] = b
                    end
          Severity: Major
          Found in lib/active_merchant/billing/gateways/iridium.rb and 4 other locations - About 30 mins to fix
          lib/active_merchant/billing/gateways/iridium.rb on lines 429..434
          lib/active_merchant/billing/gateways/iridium.rb on lines 443..446
          lib/active_merchant/billing/gateways/iridium.rb on lines 447..450
          lib/active_merchant/billing/gateways/iridium.rb on lines 451..454

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

          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

                  when 'CustomVariables'
                    reply[:custom_variables] = {}
                    node.attributes.each { |a, b| reply[:custom_variables][a.underscore.to_sym] = b }
                    node.elements.each { |e| parse_element(reply[:custom_variables], e) } if node.has_elements?
          Severity: Major
          Found in lib/active_merchant/billing/gateways/iridium.rb and 4 other locations - About 30 mins to fix
          lib/active_merchant/billing/gateways/iridium.rb on lines 429..434
          lib/active_merchant/billing/gateways/iridium.rb on lines 436..441
          lib/active_merchant/billing/gateways/iridium.rb on lines 443..446
          lib/active_merchant/billing/gateways/iridium.rb on lines 451..454

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

          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