Shopify/active_merchant

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

Summary

Maintainability
F
1 wk
Test Coverage

File cyber_source.rb has 977 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    # Initial setup instructions can be found in
    # http://apps.cybersource.com/library/documentation/dev_guides/SOAP_Toolkits/SOAP_toolkits.pdf
    #
Severity: Major
Found in lib/active_merchant/billing/gateways/cyber_source.rb - About 2 days to fix

    Class CyberSourceGateway has 102 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class CyberSourceGateway < Gateway
          self.test_url = 'https://ics2wstesta.ic3.com/commerce/1.x/transactionProcessor'
          self.live_url = 'https://ics2wsa.ic3.com/commerce/1.x/transactionProcessor'
    
          # Schema files can be found here: https://ics2ws.ic3.com/commerce/1.x/transactionProcessor/
    Severity: Major
    Found in lib/active_merchant/billing/gateways/cyber_source.rb - About 1 day to fix

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

            def add_address(xml, payment_method, address, options, shipTo = false)
              first_name, last_name = address_names(address[:name], payment_method)
              bill_to_merchant_tax_id = options[:merchant_tax_id] unless shipTo
      
              xml.tag! shipTo ? 'shipTo' : 'billTo' do
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/cyber_source.rb - About 5 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_auth_network_tokenization has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_auth_network_tokenization(xml, payment_method, options)
              return unless network_tokenization?(payment_method)
      
              commerce_indicator = 'internet' if subsequent_nt_apple_pay_auth(payment_method.source, options)
      
      
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/cyber_source.rb - About 4 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_auth_service has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_auth_service(xml, payment_method, options)
              if network_tokenization?(payment_method)
                add_auth_network_tokenization(xml, payment_method, options)
              else
                xml.tag! 'ccAuthService', { 'run' => 'true' } do
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/cyber_source.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_subscription has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_subscription(xml, options, reference = nil)
              options[:subscription] ||= {}
      
              xml.tag! 'recurringSubscriptionInfo' do
                if reference
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/cyber_source.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_normalized_threeds_2_data has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_normalized_threeds_2_data(xml, payment_method, options)
              threeds_2_options = options[:three_d_secure]
              cc_brand = card_brand(payment_method).to_sym
      
              return if threeds_2_options[:cavv].blank? && infer_commerce_indicator?(options, cc_brand)
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/cyber_source.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_installments has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_installments(xml, options)
              return unless %i[installment_total_count installment_total_amount installment_plan_type first_installment_date installment_annual_interest_rate installment_grace_period_duration].any? { |gsf| options.include?(gsf) }
      
              xml.tag! 'installment' do
                xml.tag!('totalCount', options[:installment_total_count]) if options[:installment_total_count]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/cyber_source.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_merchant_descriptor has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_merchant_descriptor(xml, options)
              return unless options[:merchant_descriptor] || options[:user_po] || options[:taxable] || options[:reference_data_code] || options[:invoice_number]
      
              xml.tag! 'invoiceHeader' do
                xml.tag! 'merchantDescriptor', options[:merchant_descriptor] if options[:merchant_descriptor]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/cyber_source.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_merchant_description has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_merchant_description(xml, options)
              return unless options[:merchant_descriptor_name] || options[:merchant_descriptor_address1] || options[:merchant_descriptor_locality]
      
              xml.tag! 'merchantInformation' do
                xml.tag! 'merchantDescriptor' do
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/cyber_source.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 12 (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/cyber_source.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_stored_credential_options has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_stored_credential_options(xml, options = {})
              return unless options[:stored_credential] || options[:stored_credential_overrides]
      
              stored_credential_subsequent_auth_first = 'true' if options.dig(:stored_credential, :initial_transaction)
              stored_credential_transaction_id = options.dig(:stored_credential, :network_transaction_id) if options.dig(:stored_credential, :initiator) == 'merchant'
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/cyber_source.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 build_purchase_request has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def build_purchase_request(money, payment_method_or_reference, options)
              xml = Builder::XmlMarkup.new indent: 2
              add_customer_id(xml, options)
              add_payment_method_or_subscription(xml, money, payment_method_or_reference, options)
              add_threeds_2_ucaf_data(xml, payment_method_or_reference, options)
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/cyber_source.rb - About 1 hr to fix

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

              def add_purchase_data(xml, money = 0, include_grand_total = false, options = {})
                xml.tag! 'purchaseTotals' do
                  xml.tag! 'currency', options[:currency] || currency(money)
                  xml.tag!('discountManagementIndicator', options[:discount_management_indicator]) if options[:discount_management_indicator]
                  xml.tag!('taxAmount', options[:purchase_tax_amount]) if options[:purchase_tax_amount]
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/cyber_source.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 build_create_subscription_request has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def build_create_subscription_request(payment_method, options)
                default_subscription_params = { frequency: 'on-demand', amount: 0, automatic_renew: false }
                options[:subscription] = default_subscription_params.update(
                  options[:subscription] || {}
                )
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/cyber_source.rb - About 1 hr to fix

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

                def build_create_subscription_request(payment_method, options)
                  default_subscription_params = { frequency: 'on-demand', amount: 0, automatic_renew: false }
                  options[:subscription] = default_subscription_params.update(
                    options[:subscription] || {}
                  )
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/cyber_source.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_other_tax has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def add_other_tax(xml, options)
                  return unless %i[vat_tax_rate local_tax_amount national_tax_amount national_tax_indicator].any? { |gsf| options.include?(gsf) }
          
                  xml.tag! 'otherTax' do
                    xml.tag! 'vatTaxRate', options[:vat_tax_rate] if options[:vat_tax_rate]
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/cyber_source.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_auth_network_tokenization has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def add_auth_network_tokenization(xml, payment_method, options)
                  return unless network_tokenization?(payment_method)
          
                  commerce_indicator = 'internet' if subsequent_nt_apple_pay_auth(payment_method.source, options)
          
          
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/cyber_source.rb - About 1 hr to fix

            Method add_line_item_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                  def add_line_item_data(xml, options)
                    return unless options[:line_items]
            
                    options[:line_items].each_with_index do |value, index|
                      xml.tag! 'item', { 'id' => index } do
            Severity: Minor
            Found in lib/active_merchant/billing/gateways/cyber_source.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 add_credit_service has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                  def add_credit_service(xml, options = {})
                    service = options[:use_check_service] ? 'ecCreditService' : 'ccCreditService'
                    request_tag = options[:use_check_service] ? 'debitRequestID' : 'captureRequestID'
                    options.delete :request_token if options[:use_check_service]
            
            
            Severity: Minor
            Found in lib/active_merchant/billing/gateways/cyber_source.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_purchase_request has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def build_purchase_request(money, payment_method_or_reference, options)
                    xml = Builder::XmlMarkup.new indent: 2
                    add_customer_id(xml, options)
                    add_payment_method_or_subscription(xml, money, payment_method_or_reference, options)
                    add_threeds_2_ucaf_data(xml, payment_method_or_reference, options)
            Severity: Minor
            Found in lib/active_merchant/billing/gateways/cyber_source.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_address has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

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

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

                    def commit(request, action, amount, options)
                      begin
                        raw_response = ssl_post(test? ? self.test_url : self.live_url, build_request(request, options))
                      rescue ResponseError => e
                        raw_response = e.response.body
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/cyber_source.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_mastercard_network_tokenization_ucaf_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def add_mastercard_network_tokenization_ucaf_data(xml, payment_method, options)
                      return unless network_tokenization?(payment_method) && card_brand(payment_method).to_sym == :master
              
                      commerce_indicator = 'internet' if subsequent_nt_apple_pay_auth(payment_method.source, options)
              
              
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/cyber_source.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 build_update_subscription_request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def build_update_subscription_request(reference, creditcard, options)
                      xml = Builder::XmlMarkup.new indent: 2
                      add_address(xml, creditcard, options[:billing_address], options) unless options[:billing_address].blank?
                      add_purchase_data(xml, options[:setup_fee], true, options) unless options[:setup_fee].blank?
                      add_creditcard(xml, creditcard)    if creditcard
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/cyber_source.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 add_decision_manager_fields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def add_decision_manager_fields(xml, options)
                      return unless options[:decision_manager_enabled]
              
                      xml.tag! 'decisionManager' do
                        xml.tag! 'enabled', options[:decision_manager_enabled] if options[:decision_manager_enabled]
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/cyber_source.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 add_stored_credential_subsequent_auth has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def add_stored_credential_subsequent_auth(xml, options = {})
                      return unless options[:stored_credential] || options[:stored_credential_overrides]
              
                      stored_credential_subsequent_auth = 'true' if options.dig(:stored_credential, :initiator) == 'merchant'
              
              
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/cyber_source.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 add_mdd_fields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def add_mdd_fields(xml, options)
                      return unless options.keys.any? { |key| key.to_s.start_with?('mdd_field') && options[key] }
              
                      xml.tag! 'merchantDefinedData' do
                        (1..100).each do |each|
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/cyber_source.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 add_tax_service has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def add_tax_service(xml)
                      xml.tag! 'taxService', { 'run' => 'true' } do
                        xml.tag!('nexus', @options[:nexus]) unless @options[:nexus].blank?
                        xml.tag!('sellerRegistration', @options[:vat_reg_number]) unless @options[:vat_reg_number].blank?
                      end
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/cyber_source.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

                        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/cyber_source.rb and 1 other location - About 25 mins to fix
              lib/active_merchant/billing/gateways/ipg.rb on lines 392..396

              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! 'decisionManager' do
                        xml.tag! 'enabled', options[:decision_manager_enabled] if options[:decision_manager_enabled]
                        xml.tag! 'profile', options[:decision_manager_profile] if options[:decision_manager_profile]
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/cyber_source.rb and 1 other location - About 15 mins to fix
              lib/active_merchant/billing/gateways/ipg.rb on lines 228..230

              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

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

                      MultiResponse.run(:use_first_response) do |r|
                        r.process { authorize(amount, payment, options) }
                        r.process(:ignore_result) { void(r.authorization, options) } unless amount == 0
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/cyber_source.rb and 1 other location - About 15 mins to fix
              lib/active_merchant/billing/gateways/authorize_net.rb on lines 180..182

              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