activemerchant/active_merchant

View on GitHub

Showing 1,501 of 1,501 total issues

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

      def add_level2_card_and_more_tax(xml, options = {})
        if (level2 = options[:level_2_data])
          xml.tag! :PCardRequestorName, byte_limit(level2[:requestor_name], 38) if level2[:requestor_name]
          xml.tag! :PCardLocalTaxRate, byte_limit(level2[:local_tax_rate], 5) if level2[:local_tax_rate]
          # Canadian Merchants Only
Severity: Minor
Found in lib/active_merchant/billing/gateways/orbital.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

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

      CURRENCY_CODES = {
        'AED' => '784',
        'ARS' => '32',
        'AUD' => '36',
        'BRL' => '986',
Severity: Major
Found in lib/active_merchant/billing/gateways/redsys.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/redsys_rest.rb on lines 38..74

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

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

      CURRENCY_CODES = {
        'AED' => '784',
        'ARS' => '32',
        'AUD' => '36',
        'BRL' => '986',
Severity: Major
Found in lib/active_merchant/billing/gateways/redsys_rest.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/redsys.rb on lines 51..87

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

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 fields has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def fields(action)
        # Gateway expects fields in fixed order below.
        case action
        when 'PAYMENT', 'PREAUTH'
          %i[
Severity: Minor
Found in lib/active_merchant/billing/gateways/world_net.rb - About 1 hr to fix

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

              post[:card][:address_line1] = address[:address1] if address[:address1]
              post[:card][:address_line2] = address[:address2] if address[:address2]
              post[:card][:address_country] = address[:country] if address[:country]
              post[:card][:address_zip] = address[:zip] if address[:zip]
              post[:card][:address_state] = address[:state] if address[:state]
    Severity: Major
    Found in lib/active_merchant/billing/gateways/stripe.rb and 1 other location - About 1 hr to fix
    lib/active_merchant/billing/gateways/securion_pay.rb on lines 207..212

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

    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

              post[:card][:addressLine1] = address[:address1] if address[:address1]
              post[:card][:addressLine2] = address[:address2] if address[:address2]
              post[:card][:addressCountry] = address[:country] if address[:country]
              post[:card][:addressZip] = address[:zip] if address[:zip]
              post[:card][:addressState] = address[:state] if address[:state]
    Severity: Major
    Found in lib/active_merchant/billing/gateways/securion_pay.rb and 1 other location - About 1 hr to fix
    lib/active_merchant/billing/gateways/stripe.rb on lines 467..472

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

    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_payment_method has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def add_payment_method(post, payment_method, options, key = :source)
            # the key = :destination when this method is called in def credit
            post[key] = {}
            case payment_method
            when NetworkTokenizationCreditCard
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/checkout_v2.rb - About 1 hr to fix

      Method build_create_profile_request has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def build_create_profile_request(options)
              xml = Builder::XmlMarkup.new :indent => 2
              xml.tag! 'CreateRecurringPaymentsProfileReq', 'xmlns' => PAYPAL_NAMESPACE do
                xml.tag! 'CreateRecurringPaymentsProfileRequest', 'xmlns:n2' => EBAY_NAMESPACE do
                  xml.tag! 'n2:Version', API_VERSION
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb - About 1 hr to fix

        Method build_merchant_data has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def build_merchant_data(xml, data, options = {})
                # See https://sis-t.redsys.es:25443/sis/services/SerClsWSEntradaV2/wsdl/SerClsWSEntradaV2.wsdl
                # (which results from calling #webservice_url + '?WSDL', https://sis-t.redsys.es:25443/sis/services/SerClsWSEntradaV2?WSDL)
                xml.DATOSENTRADA do
                  # Basic elements
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/redsys.rb - About 1 hr to fix

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

                    post[:address] = address[:address1] if address[:address1]
                    post[:address2] = address[:address2] if address[:address2]
                    post[:city] = address[:city] if address[:city]
                    post[:region] = address[:state] if address[:state]
                    post[:country] = address[:country] if address[:country]
          Severity: Major
          Found in lib/active_merchant/billing/gateways/card_connect.rb and 1 other location - About 1 hr to fix
          lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb on lines 150..156

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

          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

                    post[:fraud_remote_addr] = options[:ip] if options[:ip]
                    post[:fraud_http_accept] = options[:fraud_http_accept] if options[:fraud_http_accept]
                    post[:fraud_http_accept_language] = options[:fraud_http_accept_language] if options[:fraud_http_accept_language]
                    post[:fraud_http_accept_encoding] = options[:fraud_http_accept_encoding] if options[:fraud_http_accept_encoding]
                    post[:fraud_http_accept_charset] = options[:fraud_http_accept_charset] if options[:fraud_http_accept_charset]
          lib/active_merchant/billing/gateways/card_connect.rb on lines 178..184

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

          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 build_new_order_xml has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def build_new_order_xml(action, money, payment_source, parameters = {})
                  requires!(parameters, :order_id)
                  @use_secondary_url = parameters[:use_secondary_url] if parameters[:use_secondary_url]
                  xml = xml_envelope
                  xml.tag! :Request do
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/orbital.rb - About 1 hr to fix

            Method post_data has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                  def post_data(params)
                    return nil unless params
            
                    params.map do |key, value|
                      next if value.blank?
            Severity: Minor
            Found in lib/active_merchant/billing/gateways/cecabank/cecabank_xml.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_xml_request has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                  def build_xml_request(action, data)
                    xml = Builder::XmlMarkup.new indent: 2
                    xml.Request(version: '1.0') do
                      xml.Header do
                        xml.Security(sender: @options[:sender], type: 'MERCHANT')
            Severity: Minor
            Found in lib/active_merchant/billing/gateways/bank_frick.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_extra_options has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                  def add_extra_options(post, options)
                    extra = {}
                    extra[:ecm] = '32' if options[:recurring]
                    extra[:name] = options[:merchant] if options[:merchant]
                    extra[:location] = options[:merchant_location] if options[:merchant_location]
            Severity: Minor
            Found in lib/active_merchant/billing/gateways/fat_zebra.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 has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                  def add_customer(xml, options)
                    customer = options[:customer]
                    return unless customer
            
                    xml.tag!('customer') do
            Severity: Minor
            Found in lib/active_merchant/billing/gateways/authorize_net_arb.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_network_tokenization_card has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                  def add_network_tokenization_card(post, payment, options)
                    if options.dig(:stored_credential, :initiator) == 'merchant'
                      post[:paymentInformation][:tokenizedCard] = {
                        number: payment.number,
                        expirationMonth: payment.month,
            Severity: Minor
            Found in lib/active_merchant/billing/gateways/cyber_source_rest.rb - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

                  def add_address(post, options)
                    if address = options[:shipping_address]
                      post[:deliveryAddress] = {}
                      post[:deliveryAddress][:street] = options[:address_override] == true ? address[:address2] : address[:address1] || 'NA'
                      post[:deliveryAddress][:houseNumberOrName] = options[:address_override] == true ? address[:address1] : address[:address2] || 'NA'
            Severity: Minor
            Found in lib/active_merchant/billing/gateways/adyen.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_extra_data has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                  def add_extra_data(post, payment, options)
                    post[:telephoneNumber] = (options[:billing_address][:phone_number] if options.dig(:billing_address, :phone_number)) || (options[:billing_address][:phone] if options.dig(:billing_address, :phone)) || ''
                    post[:selectedBrand] = options[:selected_brand] if options[:selected_brand] && !post[:selectedBrand]
                    post[:deliveryDate] = options[:delivery_date] if options[:delivery_date]
                    post[:merchantOrderReference] = options[:merchant_order_reference] if options[:merchant_order_reference]
            Severity: Minor
            Found in lib/active_merchant/billing/gateways/adyen.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 14 (exceeds 5 allowed). Consider refactoring.
            Open

                  def add_customer_data(post, options)
                    post[:d1] = options[:ip] || '127.0.0.1'
                    if (billing_address = options[:billing_address])
                      post[:c5]   = billing_address[:address1]  if billing_address[:address1]
                      post[:c7]   = billing_address[:city]      if billing_address[:city]
            Severity: Minor
            Found in lib/active_merchant/billing/gateways/credorax.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

            Severity
            Category
            Status
            Source
            Language