Shopify/active_merchant

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

Summary

Maintainability
F
4 days
Test Coverage

Class IpgGateway has 42 methods (exceeds 20 allowed). Consider refactoring.
Open

    class IpgGateway < Gateway
      self.test_url = 'https://test.ipg-online.com/ipgapi/services'
      self.live_url = 'https://www5.ipg-online.com/ipgapi/services'

      self.supported_countries = %w(AR)
Severity: Minor
Found in lib/active_merchant/billing/gateways/ipg.rb - About 5 hrs to fix

    File ipg.rb has 362 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module ActiveMerchant #:nodoc:
      module Billing #:nodoc:
        class IpgGateway < Gateway
          self.test_url = 'https://test.ipg-online.com/ipgapi/services'
          self.live_url = 'https://www5.ipg-online.com/ipgapi/services'
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/ipg.rb - About 4 hrs to fix

      Method add_transaction_details has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_transaction_details(xml, options, pre_order = false)
              requires!(options, :order_id) if pre_order
              xml.tag!('v1:TransactionDetails') do
                xml.tag!('v1:OrderId', options[:order_id]) if options[:order_id]
                xml.tag!('v1:MerchantTransactionId', options[:merchant_transaction_id]) if options[:merchant_transaction_id]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/ipg.rb - About 3 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_billing has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_billing(xml, billing)
              xml.tag!('v1:Billing') do
                xml.tag!('v1:CustomerID', billing[:customer_id]) if billing[:customer_id]
                xml.tag!('v1:Name', billing[:name]) if billing[:name]
                xml.tag!('v1:Company', billing[:company]) if billing[:company]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/ipg.rb - About 3 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_credit_card has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_credit_card(xml, payment, options = {}, credit_envelope = 'v1')
              if payment&.is_a?(CreditCard)
                requires!(options.merge!({ card_number: payment.number, month: payment.month, year: payment.year }), :card_number, :month, :year)
      
                xml.tag!("#{credit_envelope}:CreditCardData") do
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/ipg.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_shipping has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_shipping(xml, shipping)
              xml.tag!('v1:Shipping') do
                xml.tag!('v1:Type', shipping[:type]) if shipping[:type]
                xml.tag!('v1:Name', shipping[:name]) if shipping[:name]
                xml.tag!('v1:Address1', shipping[:address_1]) if shipping[:address_1]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/ipg.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_payment has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_payment(xml, money, payment, options)
              requires!(options.merge!({ money: money }), :currency, :money)
              xml.tag!('v1:Payment') do
                xml.tag!('v1:HostedDataID', payment) if payment&.is_a?(String)
                xml.tag!('v1:HostedDataStoreID', options[:hosted_data_store_id]) if options[:hosted_data_store_id]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/ipg.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 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_address(xml, address)
              xml.tag!('v1:Address') do
                xml.tag!('v1:Address1', address[:address1]) if address[:address1]
                xml.tag!('v1:Address2', address[:address2]) if address[:address2]
                xml.tag!('v1:Zip', address[:zip]) if address[:zip]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/ipg.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_three_d_secure has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_three_d_secure(xml, three_d_secure)
              xml.tag!('v1:CreditCard3DSecure') do
                xml.tag!('v1:AuthenticationValue', three_d_secure[:cavv]) if three_d_secure[:cavv]
                xml.tag!('v1:XID', three_d_secure[:xid]) if three_d_secure[:xid]
                xml.tag!('v1:Secure3D2TransactionStatus', three_d_secure[:directory_response_status]) if three_d_secure[:directory_response_status]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/ipg.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_sub_merchant has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_sub_merchant(xml, submerchant)
              xml.tag!('v1:SubMerchant') do
                xml.tag!('v1:Mcc', submerchant[:mcc]) if submerchant[:mcc]
                xml.tag!('v1:LegalName', submerchant[:legal_name]) if submerchant[:legal_name]
                add_address(xml, submerchant[:address]) if submerchant[:address]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/ipg.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 parse_element has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse_element(reply, node)
              if node.has_elements?
                node.elements.each { |e| parse_element(reply, e) }
              else
                if /item/.match?(node.parent.name)
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/ipg.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 build_soap_request has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def build_soap_request(action, body)
              xml = Builder::XmlMarkup.new(indent: 2)
              xml.tag!('soapenv:Envelope', envelope_namespaces) do
                xml.tag!('soapenv:Header')
                xml.tag!('soapenv:Body') do
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/ipg.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_storage_item has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_storage_item(xml, credit_card, options)
              requires!(options.merge!({ credit_card: credit_card, hosted_data_id: @hosted_data_id }), :credit_card, :hosted_data_id)
              xml.tag!('ns2:StoreHostedData') do
                xml.tag!('ns2:DataStorageItem') do
                  add_credit_card(xml, credit_card, {}, 'ns2')
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/ipg.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

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

            def build_purchase_and_authorize_request(money, payment, options)
              xml = Builder::XmlMarkup.new(indent: 2)
      
              add_credit_card(xml, payment, options)
              add_sub_merchant(xml, options[:submerchant]) if options[:submerchant]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/ipg.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 2 locations. Consider refactoring.
      Open

            def add_address(xml, address)
              xml.tag!('v1:Address') do
                xml.tag!('v1:Address1', address[:address1]) if address[:address1]
                xml.tag!('v1:Address2', address[:address2]) if address[:address2]
                xml.tag!('v1:Zip', address[:zip]) if address[:zip]
      Severity: Major
      Found in lib/active_merchant/billing/gateways/ipg.rb and 1 other location - About 1 hr to fix
      lib/active_merchant/billing/gateways/ipg.rb on lines 234..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 67.

      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 2 locations. Consider refactoring.
      Open

            def add_three_d_secure(xml, three_d_secure)
              xml.tag!('v1:CreditCard3DSecure') do
                xml.tag!('v1:AuthenticationValue', three_d_secure[:cavv]) if three_d_secure[:cavv]
                xml.tag!('v1:XID', three_d_secure[:xid]) if three_d_secure[:xid]
                xml.tag!('v1:Secure3D2TransactionStatus', three_d_secure[:directory_response_status]) if three_d_secure[:directory_response_status]
      Severity: Major
      Found in lib/active_merchant/billing/gateways/ipg.rb and 1 other location - About 1 hr to fix
      lib/active_merchant/billing/gateways/ipg.rb on lines 216..223

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

      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

                if /item/.match?(node.parent.name)
                  parent = node.parent.name
                  parent += '_' + node.parent.attributes['id'] if node.parent.attributes['id']
                  parent += '_'
                end
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/ipg.rb and 1 other location - About 25 mins to fix
      lib/active_merchant/billing/gateways/cyber_source.rb on lines 1180..1184

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

      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 2 locations. Consider refactoring.
      Open

              xml.tag!('v1:Document') do
                xml.tag!('v1:Type', document[:type]) if document[:type]
                xml.tag!('v1:Number', document[:number]) if document[:number]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/ipg.rb and 1 other location - About 15 mins to fix
      lib/active_merchant/billing/gateways/cyber_source.rb on lines 686..688

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

      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