activemerchant/active_merchant

View on GitHub

Showing 1,501 of 1,501 total issues

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

      def add_billing_address(post, payment, options)
        return unless billing = options[:billing_address]

        billing_address = {}
        name_from_address(billing_address, billing) || name_from_payment(billing_address, payment)
Severity: Minor
Found in lib/active_merchant/billing/gateways/commerce_hub.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 authorize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def authorize(money, payment_method, options = {})
        MultiResponse.run do |r|
          if payment_method.is_a?(CreditCard)
            response = r.process { tokenize(payment_method, options) }
            card_token = response.params['token']
Severity: Minor
Found in lib/active_merchant/billing/gateways/hi_pay.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 commit_raw has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def commit_raw(object, action, parameters)
        if action == 'inquire'
          url = "#{test? ? test_url : live_url}#{object}/#{parameters}"
          begin
            raw_response = ssl_get(url, headers)
Severity: Minor
Found in lib/active_merchant/billing/gateways/paymentez.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_airline_data has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def add_airline_data(post, options)
        return unless airline_options = options[:airline_data]

        airline_data = {}

Severity: Minor
Found in lib/active_merchant/billing/gateways/global_collect.rb - About 1 hr to fix

Cognitive Complexity

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

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

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

Further reading

Method add_stored_credential has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def add_stored_credential(post, options)
        add_transaction_type(post, options)
        # if :transaction_type option is not passed, then check for :stored_credential options
        return unless (stored_credential = options[:stored_credential]) && options.dig(:transaction_type).nil?

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

Method add_payment has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def add_payment(post, payment, options = {})
        if payment.is_a?(String)
          token, bin = payment.split('|')
          post[:token] = token
          post[:bin] = bin
Severity: Minor
Found in lib/active_merchant/billing/gateways/decidir_plus.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_payment_method_id has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def add_payment_method_id(credit_card, options)
        if options[:payment_method_id]
          options[:payment_method_id].to_i
        elsif options[:debit]
          if CreditCard.brand?(credit_card.number) == 'visa'
Severity: Minor
Found in lib/active_merchant/billing/gateways/decidir.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 error_code_from has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def error_code_from(response)
        return if success_from(response)

        error_code = nil
        if error = response.dig('status_details', 'error')
Severity: Minor
Found in lib/active_merchant/billing/gateways/decidir_plus.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 commit has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def commit(endpoint, post)
        raw_response = ssl_post(url() + endpoint, post_data(post), headers)
        response = parse(raw_response)
      rescue ResponseError => e
        raw_response = e.response.body
Severity: Minor
Found in lib/active_merchant/billing/gateways/latitude19.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 post_data has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def post_data(money, creditcard, options)
        params = parameters(money, creditcard, options)

        xml = REXML::Document.new
        order = xml.add_element('order')
Severity: Minor
Found in lib/active_merchant/billing/gateways/linkpoint.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

      def post_data(action, parameters = {})
        post = {}

        post[:version]        = API_VERSION
        post[:login]          = @options[:login]
Severity: Major
Found in lib/active_merchant/billing/gateways/secure_pay.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/metrics_global.rb on lines 211..224

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

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

      def post_data(action, parameters = {})
        post = {}

        post[:version]        = API_VERSION
        post[:login]          = @options[:login]
Severity: Major
Found in lib/active_merchant/billing/gateways/metrics_global.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/secure_pay.rb on lines 94..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 65.

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(money, payment, options = {})
        requires!(options, :order_id)

        data = {}
        add_action(data, :purchase, options)
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.rb on lines 216..232

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

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(money, payment, options = {})
        requires!(options, :order_id)

        data = {}
        add_action(data, :authorize, options)
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.rb on lines 197..213

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

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

      def add_d3d(post, options)
        add_pair post, 'FLAG3D', 'Y'
        win_3ds = THREE_D_SECURE_DISPLAY_WAYS.key?(options[:win_3ds]) ?
          THREE_D_SECURE_DISPLAY_WAYS[options[:win_3ds]] :
          THREE_D_SECURE_DISPLAY_WAYS[:main_window]
Severity: Minor
Found in lib/active_merchant/billing/gateways/ogone.rb - About 1 hr to fix

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

          def error_code_from(response)
            unless success_from(response)
              case response['errorCode']
              when '3002' then STANDARD_ERROR_CODE[:invalid_number] # You submitted an invalid card number or brand or combination of card number and brand with your request.
              when '3004' then STANDARD_ERROR_CODE[:incorrect_zip] # The zip/postal code must be provided for an AVS check request.
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/netbanx.rb - About 1 hr to fix

      Method add_address has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def add_address(xml, creditcard, options)
              return unless creditcard
      
              if address = options[:billing_address] || options[:address]
                xml.tag!('CUSTOMER_BILL') do
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/secure_net.rb - About 1 hr to fix

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

              def add_customer_data(post, options)
                post[:email] = options[:email]
                post[:ipaddress] = options[:ip]
                post[:customer_id] = options[:customer_id] || options[:customer]
        
        
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/nmi.rb - About 1 hr to fix

          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

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

                  def authorize(amount, payment, options = {})
                    post = PostData.new
                    add_invoice(post, amount, options)
                    add_payment(post, payment)
                    add_address(post, payment, options)
            Severity: Major
            Found in lib/active_merchant/billing/gateways/transact_pro.rb and 1 other location - About 1 hr to fix
            lib/active_merchant/billing/gateways/transact_pro.rb on lines 25..42

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

            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

            Severity
            Category
            Status
            Source
            Language