Shopify/active_merchant

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

Summary

Maintainability
F
1 wk
Test Coverage

File authorize_net.rb has 984 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'nokogiri'

module ActiveMerchant
  module Billing
    class AuthorizeNetGateway < Gateway
Severity: Major
Found in lib/active_merchant/billing/gateways/authorize_net.rb - About 2 days to fix

    Class AuthorizeNetGateway has 79 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class AuthorizeNetGateway < Gateway
          include Empty
    
          self.test_url = 'https://apitest.authorize.net/xml/v1/request.api'
          self.live_url = 'https://api2.authorize.net/xml/v1/request.api'
    Severity: Major
    Found in lib/active_merchant/billing/gateways/authorize_net.rb - About 1 day to fix

      Method parse_normal has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse_normal(action, body)
              doc = Nokogiri::XML(body)
              doc.remove_namespaces!
      
              response = { action: action }
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/authorize_net.rb - About 6 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 parse_cim has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse_cim(body, options)
              response = {}
      
              doc = Nokogiri::XML(body).remove_namespaces!
      
      
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/authorize_net.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_settings has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_settings(xml, source, options)
              xml.transactionSettings do
                if options[:recurring] || subsequent_recurring_transaction?(options)
                  xml.setting do
                    xml.settingName('recurringBilling')
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/authorize_net.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 parse_normal has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def parse_normal(action, body)
              doc = Nokogiri::XML(body)
              doc.remove_namespaces!
      
              response = { action: action }
      Severity: Major
      Found in lib/active_merchant/billing/gateways/authorize_net.rb - About 2 hrs to fix

        Method add_billing_address has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

              def add_billing_address(xml, payment_source, options)
                address = options[:billing_address] || options[:address] || {}
        
                xml.billTo do
                  first_name, last_name = names_from(payment_source, address, options)
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/authorize_net.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 parse_direct_response_elements has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def parse_direct_response_elements(response, options)
                params = response[:direct_response]&.tr('"', '')
                return {} unless params
        
                parts = params.split(options[:delimiter] || ',')
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/authorize_net.rb - About 2 hrs to fix

          Method add_shipping_address has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

                def add_shipping_address(xml, options, root_node = 'shipTo')
                  address = options[:shipping_address] || options[:address]
                  return unless address
          
                  xml.send(root_node) do
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/authorize_net.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_settings has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def add_settings(xml, source, options)
                  xml.transactionSettings do
                    if options[:recurring] || subsequent_recurring_transaction?(options)
                      xml.setting do
                        xml.settingName('recurringBilling')
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/authorize_net.rb - About 1 hr to fix

            Method parse_cim has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def parse_cim(body, options)
                    response = {}
            
                    doc = Nokogiri::XML(body).remove_namespaces!
            
            
            Severity: Minor
            Found in lib/active_merchant/billing/gateways/authorize_net.rb - About 1 hr to fix

              Method normal_refund has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def normal_refund(amount, authorization, options)
                      transaction_id, card_number, = split_authorization(authorization)
              
                      commit(:refund) do |xml|
                        xml.transactionRequest do
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/authorize_net.rb - About 1 hr to fix

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

                      def normal_refund(amount, authorization, options)
                        transaction_id, card_number, = split_authorization(authorization)
                
                        commit(:refund) do |xml|
                          xml.transactionRequest do
                Severity: Minor
                Found in lib/active_merchant/billing/gateways/authorize_net.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_customer_data has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                      def add_customer_data(xml, payment_source, options)
                        xml.customer do
                          xml.id(options[:customer]) unless empty?(options[:customer]) || options[:customer] !~ /^\w+$/
                          xml.email(options[:email]) unless empty?(options[:email])
                        end
                Severity: Minor
                Found in lib/active_merchant/billing/gateways/authorize_net.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 create_customer_profile has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def create_customer_profile(credit_card, options)
                        commit(:cim_store, options) do |xml|
                          xml.profile do
                            xml.merchantCustomerId(truncate(options[:merchant_customer_id], 20) || SecureRandom.hex(10))
                            xml.description(truncate(options[:description], 255)) unless empty?(options[:description])
                Severity: Minor
                Found in lib/active_merchant/billing/gateways/authorize_net.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 amount_for_verify has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def amount_for_verify(options)
                        return 100 unless options[:verify_amount].present?
                
                        amount = options[:verify_amount]
                        raise ArgumentError.new 'verify_amount value must be an integer' unless amount.is_a?(Integer) && !amount.negative? || amount.is_a?(String) && amount.match?(/^\d+$/) && !amount.to_i.negative?
                Severity: Minor
                Found in lib/active_merchant/billing/gateways/authorize_net.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_ship_from_address has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def add_ship_from_address(xml, options, root_node = 'shipFrom')
                        address = options[:ship_from_address]
                        return unless address
                
                        xml.send(root_node) do
                Severity: Minor
                Found in lib/active_merchant/billing/gateways/authorize_net.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_processing_options has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def add_processing_options(xml, options)
                        return unless options[:stored_credential]
                
                        xml.processingOptions do
                          if options[:stored_credential][:initial_transaction] && options[:stored_credential][:reason_type] == 'recurring'
                Severity: Minor
                Found in lib/active_merchant/billing/gateways/authorize_net.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_surcharge_fields has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def add_surcharge_fields(xml, options)
                        surcharge = options[:surcharge] if options[:surcharge]
                        if surcharge.is_a?(Hash)
                          xml.surcharge do
                            xml.amount(amount(surcharge[:amount].to_i)) if surcharge[:amount]
                Severity: Minor
                Found in lib/active_merchant/billing/gateways/authorize_net.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_cim_auth_purchase has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                      def add_cim_auth_purchase(xml, transaction_type, amount, payment, options)
                Severity: Minor
                Found in lib/active_merchant/billing/gateways/authorize_net.rb - About 35 mins to fix

                  Method add_auth_purchase has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                        def add_auth_purchase(xml, transaction_type, amount, payment, options)
                  Severity: Minor
                  Found in lib/active_merchant/billing/gateways/authorize_net.rb - About 35 mins to fix

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

                          def refund(amount, authorization, options = {})
                            response =
                              if auth_was_for_cim?(authorization)
                                cim_refund(amount, authorization, options)
                              else
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/authorize_net.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_market_type_device_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def add_market_type_device_type(xml, payment, options)
                            return unless payment.is_a?(CreditCard)
                            return if payment.is_a?(NetworkTokenizationCreditCard)
                    
                            if valid_track_data
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/authorize_net.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_payment_method has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def add_payment_method(xml, payment_method, options, action = nil)
                            return unless payment_method
                    
                            case payment_method
                            when String
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/authorize_net.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 root_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def root_for(action)
                            if action == :cim_store
                              'createCustomerProfileRequest'
                            elsif action == :cim_store_update
                              'createCustomerPaymentProfileRequest'
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/authorize_net.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 message_from has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def message_from(action, response, avs_result, cvv_result)
                            if response[:response_code] == DECLINED
                              if CARD_CODE_ERRORS.include?(cvv_result.code)
                                return cvv_result.message
                              elsif AVS_REASON_CODES.include?(response[:response_reason_code]) && AVS_ERRORS.include?(avs_result.code)
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/authorize_net.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_invoice has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def add_invoice(xml, transaction_type, options)
                            xml.order do
                              xml.invoiceNumber(truncate(options[:order_id], 20))
                              xml.description(truncate(options[:description], 255))
                              xml.purchaseOrderNumber(options[:po_number]) if options[:po_number] && transaction_type.start_with?('profileTrans')
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/authorize_net.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_credit_card has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def add_credit_card(xml, credit_card, action)
                            if credit_card.track_data
                              add_swipe_data(xml, credit_card)
                            else
                              xml.payment do
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/authorize_net.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_subsequent_auth_information has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def add_subsequent_auth_information(xml, options)
                            return unless options.dig(:stored_credential, :initiator) == 'merchant'
                    
                            xml.subsequentAuthInformation do
                              xml.reason options[:stored_credential_reason_type_override] if options[:stored_credential_reason_type_override]
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/authorize_net.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

                          STANDARD_ERROR_CODE_MAPPING = {
                            '2127' => STANDARD_ERROR_CODE[:incorrect_address],
                            '22' => STANDARD_ERROR_CODE[:card_declined],
                            '227' => STANDARD_ERROR_CODE[:incorrect_address],
                            '23' => STANDARD_ERROR_CODE[:card_declined],
                    Severity: Major
                    Found in lib/active_merchant/billing/gateways/authorize_net.rb and 1 other location - About 2 hrs to fix
                    lib/active_merchant/billing/gateways/simetrik.rb on lines 21..40

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

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

                          def add_shipping_fields(xml, options)
                            shipping = options[:shipping]
                            if shipping.is_a?(Hash)
                              xml.shipping do
                                xml.amount(amount(shipping[:amount].to_i))
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/authorize_net.rb and 2 other locations - About 25 mins to fix
                    lib/active_merchant/billing/gateways/authorize_net.rb on lines 692..698
                    lib/active_merchant/billing/gateways/authorize_net.rb on lines 703..709

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

                          def add_tax_fields(xml, options)
                            tax = options[:tax]
                            if tax.is_a?(Hash)
                              xml.tax do
                                xml.amount(amount(tax[:amount].to_i))
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/authorize_net.rb and 2 other locations - About 25 mins to fix
                    lib/active_merchant/billing/gateways/authorize_net.rb on lines 703..709
                    lib/active_merchant/billing/gateways/authorize_net.rb on lines 724..730

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

                          def add_duty_fields(xml, options)
                            duty = options[:duty]
                            if duty.is_a?(Hash)
                              xml.duty do
                                xml.amount(amount(duty[:amount].to_i))
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/authorize_net.rb and 2 other locations - About 25 mins to fix
                    lib/active_merchant/billing/gateways/authorize_net.rb on lines 692..698
                    lib/active_merchant/billing/gateways/authorize_net.rb on lines 724..730

                    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

                          def scrub(transcript)
                            transcript.
                              gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
                              gsub(%r((<transactionKey>).+(</transactionKey>)), '\1[FILTERED]\2').
                              gsub(%r((<cardNumber>).+(</cardNumber>)), '\1[FILTERED]\2').
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/authorize_net.rb and 1 other location - About 25 mins to fix
                    lib/active_merchant/billing/gateways/litle.rb on lines 237..247

                    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

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

                          def purchase(amount, payment, options = {})
                            if payment.is_a?(String)
                              commit(:cim_purchase, options) do |xml|
                                add_cim_auth_purchase(xml, 'profileTransAuthCapture', amount, payment, options)
                              end
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/authorize_net.rb and 1 other location - About 25 mins to fix
                    lib/active_merchant/billing/gateways/authorize_net.rb on lines 112..119

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

                    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 authorize(amount, payment, options = {})
                            if payment.is_a?(String)
                              commit(:cim_authorize, options) do |xml|
                                add_cim_auth_purchase(xml, 'profileTransAuthOnly', amount, payment, options)
                              end
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/authorize_net.rb and 1 other location - About 25 mins to fix
                    lib/active_merchant/billing/gateways/authorize_net.rb on lines 100..107

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

                    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

                          STANDARD_AVS_CODE_MAPPING = {
                            'A' => 'A', # Street Address: Match -- First 5 Digits of ZIP: No Match
                            'B' => 'I', # Address not provided for AVS check or street address match, postal code could not be verified
                            'E' => 'E', # AVS Error
                            'G' => 'G', # Non U.S. Card Issuing Bank
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/authorize_net.rb and 4 other locations - About 20 mins to fix
                    lib/active_merchant/billing/gateways/migs/migs_codes.rb on lines 56..69
                    lib/active_merchant/billing/gateways/paypal_express.rb on lines 13..26
                    lib/active_merchant/billing/gateways/plugnpay.rb on lines 21..34
                    lib/active_merchant/billing/gateways/trust_commerce.rb on lines 72..85

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

                    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_method, options) }
                              r.process(:ignore_result) { void(r.authorization, options) } unless amount == 0
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/authorize_net.rb and 1 other location - About 15 mins to fix
                    lib/active_merchant/billing/gateways/cyber_source.rb on lines 220..222

                    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