activemerchant/active_merchant

View on GitHub

Showing 1,501 of 1,501 total issues

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

      def transaction_element(action, parameters)
        transaction = REXML::Element.new(action)

        # Must add the elements in the correct order
        actions[action].each do |key|
Severity: Minor
Found in lib/active_merchant/billing/gateways/moneris.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 add_address has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def add_address(post, options)
        if address = options[:billing_address] || options[:address]
          post[:address] = address[:address1] if address[:address1]
          post[:address2] = address[:address2] if address[:address2]
          post[:city] = address[:city] if address[:city]
Severity: Minor
Found in lib/active_merchant/billing/gateways/card_connect.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 add_address has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def add_address(post, options)
        if (address = (options[:billing_address] || options[:address]))
          post[:address] = {}
          post[:address][:street1] = address[:address1] if address[:address1]
          post[:address][:street2] = address[:address2] if address[:address2]
Severity: Minor
Found in lib/active_merchant/billing/gateways/conekta.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 add_address has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def add_address(post, options)
        return unless post[:card]&.kind_of?(Hash)

        if address = options[:billing_address] || options[:address]
          post[:card][:address_line1] = address[:address1] if address[:address1]
Severity: Minor
Found in lib/active_merchant/billing/gateways/stripe.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 post_data has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def post_data(params)
        return nil unless params

        params.map do |key, value|
          next if value != false && value.blank?
Severity: Minor
Found in lib/active_merchant/billing/gateways/pagarme.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 add_billing_address has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def add_billing_address(xml, creditcard, options)
        address = options[:billing_address]
        return unless address

        xml.billing do
Severity: Minor
Found in lib/active_merchant/billing/gateways/maxipago.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 add_shipping has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def add_shipping(xml, shipping)
        xml.tag!('v1:Shipping') do
          xml.tag!('v1:Type', shipping[:type]) if shipping[:type]
          xml.tag!('v1:Name', shipping[:name]) if shipping[:name]
          xml.tag!('v1:Address1', shipping[:address_1]) if shipping[:address_1]
Severity: Minor
Found in lib/active_merchant/billing/gateways/ipg.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 has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def parse_direct_response(params)
        delimiter = @options[:delimiter] || ','
        direct_response = { 'raw' => params }
        direct_response_fields = params.split(delimiter)
        direct_response.merge(
Severity: Major
Found in lib/active_merchant/billing/gateways/authorize_net_cim.rb - About 2 hrs to fix

    File vanco.rb has 252 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'nokogiri'
    
    module ActiveMerchant
      module Billing
        class VancoGateway < Gateway
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/vanco.rb - About 2 hrs to fix

      File ixopay.rb has 252 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'nokogiri'
      
      module ActiveMerchant #:nodoc:
        module Billing #:nodoc:
          class IxopayGateway < Gateway
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/ixopay.rb - About 2 hrs to fix

        Method parameters has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def parameters(money, creditcard, options = {})
                params = {
                  # General order parameters
                  StoreID: @options[:login],
                  Passphrase: @options[:password],
        Severity: Major
        Found in lib/active_merchant/billing/gateways/psigate.rb - About 2 hrs to fix

          File cecabank_json.rb has 251 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'active_merchant/billing/gateways/cecabank/cecabank_common'
          
          module ActiveMerchant
            module Billing
              class CecabankJsonGateway < Gateway
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/cecabank/cecabank_json.rb - About 2 hrs to fix

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

                  def authorize(money, creditcard_or_datakey, options = {})
                    requires!(options, :order_id)
                    post = {}
                    add_payment_source(post, creditcard_or_datakey, options)
                    post[:amount] = amount(money)
            Severity: Major
            Found in lib/active_merchant/billing/gateways/moneris.rb and 1 other location - About 2 hrs to fix
            lib/active_merchant/billing/gateways/moneris.rb on lines 72..90

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

                  STANDARD_ERROR_CODE_MAPPING = {
                    'R101' => STANDARD_ERROR_CODE[:incorrect_number],
                    'R102' => STANDARD_ERROR_CODE[:invalid_number],
                    'R103' => STANDARD_ERROR_CODE[:invalid_expiry_date],
                    'R104' => STANDARD_ERROR_CODE[:invalid_cvc],
            Severity: Major
            Found in lib/active_merchant/billing/gateways/simetrik.rb and 1 other location - About 2 hrs to fix
            lib/active_merchant/billing/gateways/authorize_net.rb on lines 38..57

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

                  def purchase(money, creditcard_or_datakey, options = {})
                    requires!(options, :order_id)
                    post = {}
                    add_payment_source(post, creditcard_or_datakey, options)
                    post[:amount] = amount(money)
            Severity: Major
            Found in lib/active_merchant/billing/gateways/moneris.rb and 1 other location - About 2 hrs to fix
            lib/active_merchant/billing/gateways/moneris.rb on lines 47..65

            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

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

                    def commit(method, url, parameters = nil, options = {}, type = false)
                      raw_response = response = nil
                      success = false
                      begin
                        json = parameters ? parameters.to_json : nil
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/worldpay_online_payments.rb - About 1 hr to fix

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

                      def add_mpi_3ds(xml, three_d_secure_options)
                        # structure as per https://developer.paypal.com/api/nvp-soap/payflow/3d-secure-mpi/
                        authentication_id = three_d_secure_options[:authentication_id]
                        authentication_status = three_d_secure_options[:authentication_response_status]
                
                
                Severity: Minor
                Found in lib/active_merchant/billing/gateways/payflow.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_and_customer_info has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                      def add_address_and_customer_info(xml, options)
                        billing_address = options[:billing_address] || options[:address]
                        shipping_address = options[:shipping_address]
                        ipv4_address = ipv4?(options[:ip]) ? options[:ip] : nil
                
                
                Severity: Minor
                Found in lib/active_merchant/billing/gateways/realex.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