activemerchant/active_merchant

View on GitHub

Showing 1,501 of 1,501 total issues

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

          if address[:address2]
            post[:shipping_address]   = address[:address1].to_s << ' ' << address[:address2].to_s
          else
            post[:shipping_address]   = address[:address1].to_s
          end
Severity: Major
Found in lib/active_merchant/billing/gateways/efsnet.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/efsnet.rb on lines 113..121

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

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

          if address[:address2]
            post[:billing_address]    = address[:address1].to_s << ' ' << address[:address2].to_s
          else
            post[:billing_address]    = address[:address1].to_s
          end
Severity: Major
Found in lib/active_merchant/billing/gateways/efsnet.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/efsnet.rb on lines 125..133

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

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

Method add_credit_card has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def add_credit_card(xml, credit_card, address)
        xml.tag! :Card do
          # DataCash calls the CC number 'pan'
          xml.tag! :pan, credit_card.number
          xml.tag! :expirydate, format_date(credit_card.month, credit_card.year)
Severity: Minor
Found in lib/active_merchant/billing/gateways/data_cash.rb - About 1 hr to fix

    Method add_customer_data has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def add_customer_data(post, payment_method, options)
            billing = {}
            shipping = {}
            customer = {}
            device = {}
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/mastercard.rb - About 1 hr to fix

      Method legacy_parse has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def legacy_parse(action, xml)
              response = {}
      
              error_messages = []
              error_codes = []
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb - About 1 hr to fix

        Method add_contact has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def add_contact(doc, fullname, options)
                doc['v1'].contact do
                  doc['v1'].fullName fullname unless fullname.blank?
                  doc['v1'].coName options[:company_name] if options[:company_name]
                  doc['v1'].title options[:title] if options[:title]

          Method commit has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def commit(action, body, options, try_again = true)
                  credentials = ensure_credentials
                  payload = encrypt_payload(body, credentials, options)
          
                  if options.dig :http, :method
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/alelo.rb - About 1 hr to fix

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

                  def add_level3_vat_fields(xml, options = {})
                    if (level3 = options[:level_3_data])
                      xml.tag! :PC3InvoiceDiscTreatment, byte_limit(level3[:invoice_discount_treatment], 1) if level3[:invoice_discount_treatment]
                      xml.tag! :PC3TaxTreatment, byte_limit(level3[:tax_treatment], 1) if level3[:tax_treatment]
                      xml.tag! :PC3UniqueVATInvoiceRefNum, byte_limit(level3[:unique_vat_invoice_ref], 15) if level3[:unique_vat_invoice_ref]
            Severity: Major
            Found in lib/active_merchant/billing/gateways/orbital.rb and 2 other locations - About 1 hr to fix
            lib/active_merchant/billing/gateways/orbital.rb on lines 440..445
            lib/active_merchant/billing/gateways/orbital.rb on lines 449..454

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 58.

            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_level3_tax(xml, options = {})
                    if (level3 = options[:level_3_data])
                      xml.tag! :PC3VATtaxAmt, byte_limit(level3[:vat_tax], 12) if level3[:vat_tax]
                      xml.tag! :PC3VATtaxRate, byte_limit(level3[:vat_rate], 4) if level3[:vat_rate]
                      xml.tag! :PC3AltTaxInd, byte_limit(level3[:alt_ind], 15) if level3[:alt_ind]
            Severity: Major
            Found in lib/active_merchant/billing/gateways/orbital.rb and 2 other locations - About 1 hr to fix
            lib/active_merchant/billing/gateways/orbital.rb on lines 449..454
            lib/active_merchant/billing/gateways/orbital.rb on lines 519..524

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

            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_level2_advice_addendum(xml, options = {})
                    if (level2 = options[:level_2_data])
                      xml.tag! :AMEXTranAdvAddn1, byte_limit(level2[:advice_addendum_1], 40) if level2[:advice_addendum_1]
                      xml.tag! :AMEXTranAdvAddn2, byte_limit(level2[:advice_addendum_2], 40) if level2[:advice_addendum_2]
                      xml.tag! :AMEXTranAdvAddn3, byte_limit(level2[:advice_addendum_3], 40) if level2[:advice_addendum_3]
            Severity: Major
            Found in lib/active_merchant/billing/gateways/orbital.rb and 2 other locations - About 1 hr to fix
            lib/active_merchant/billing/gateways/orbital.rb on lines 440..445
            lib/active_merchant/billing/gateways/orbital.rb on lines 519..524

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

            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

            Consider simplifying this complex logical expression.
            Open

                    if response['refusalReason'] && response['additionalData'] && (response['additionalData']['merchantAdviceCode'] || response['additionalData']['refusalReasonRaw'])
                      "#{response['refusalReason']} | #{response['additionalData']['merchantAdviceCode'] || response['additionalData']['refusalReasonRaw']}"
                    else
                      response['refusalReason'] || response['resultCode'] || response['message'] || response['result']
                    end
            Severity: Critical
            Found in lib/active_merchant/billing/gateways/adyen.rb - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                      if address = options[:billing_address] || options[:address]
                        post[:data][:attributes][:billingAddress] = {
                          line1: address[:address1] || '',
                          line2: address[:address2] || '',
                          city: address[:city] || '',
              Severity: Critical
              Found in lib/active_merchant/billing/gateways/digitzs.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 parse has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def parse(data, action)
                          params  = {}
                          success = false
                          message = ''
                          options = @options.merge(test: test?)
                  Severity: Minor
                  Found in lib/active_merchant/billing/gateways/redsys.rb - About 1 hr to fix

                    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

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

                            AVS_MAPPING = {
                              '0'  => 'R',  # Unknown
                              '1'  => 'A',  # Address matches, postal code doesn't
                              '2'  => 'N',  # Neither postal code nor address match
                              '3'  => 'R',  # AVS unavailable
                      Severity: Major
                      Found in lib/active_merchant/billing/gateways/adyen.rb and 2 other locations - About 1 hr to fix
                      lib/active_merchant/billing/gateways/blue_snap.rb on lines 34..61
                      lib/active_merchant/billing/gateways/payway_dot_com.rb on lines 24..51

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

                      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

                            AVS_MAPPING = {
                              'N1'  => 'I', #  No address given with order
                              'N2'  => 'I', #  Bill-to address did not pass
                              '““'  => 'R', #  AVS not performed (Blanks returned)
                              'IU'  => 'G', #  AVS not performed by Issuer
                      Severity: Major
                      Found in lib/active_merchant/billing/gateways/payway_dot_com.rb and 2 other locations - About 1 hr to fix
                      lib/active_merchant/billing/gateways/adyen.rb on lines 202..229
                      lib/active_merchant/billing/gateways/blue_snap.rb on lines 34..61

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

                      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

                            AVS_CODE_TRANSLATOR = {
                              'line1: U, zip: U, name: U' => 'I',
                              'line1: U, zip: U, name: M' => 'I',
                              'line1: U, zip: U, name: N' => 'I',
                              'line1: U, zip: M, name: U' => 'P',
                      Severity: Major
                      Found in lib/active_merchant/billing/gateways/blue_snap.rb and 2 other locations - About 1 hr to fix
                      lib/active_merchant/billing/gateways/adyen.rb on lines 202..229
                      lib/active_merchant/billing/gateways/payway_dot_com.rb on lines 24..51

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

                      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

                      Method error_code_from has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def error_code_from(response)
                              unless success_from(response)
                                case response['result']['code']
                                when '100.100.101'
                                  STANDARD_ERROR_CODE[:incorrect_number]
                      Severity: Minor
                      Found in lib/active_merchant/billing/gateways/cardprocess.rb - About 1 hr to fix

                        Method add_3ds_data has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              def add_3ds_data(post, options = {})
                                three_d_secure = options[:three_ds_2]
                                # 01 => Challenge requested, 02 => Exemption requested, 03 or not sending parameter => No preference
                                challenge_preference = if [true, 'true'].include?(options[:force_3d_secure])
                                                         '01'
                        Severity: Minor
                        Found in lib/active_merchant/billing/gateways/nuvei.rb - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language