activemerchant/active_merchant

View on GitHub

Showing 999 of 1,496 total issues

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

      def commit(action, post, authorization = nil, method = :post)
        MultiResponse.run do |r|
          r.process { fetch_access_token } unless access_token_valid?
          r.process do
            api_request(action, post, authorization, method).tap do |response|
Severity: Minor
Found in lib/active_merchant/billing/gateways/flex_charge.rb - About 35 mins to fix

Cognitive Complexity

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

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

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

Further reading

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

      def initialize(attrs)
        attrs ||= {}

        @code = attrs[:code].upcase unless attrs[:code].blank?
        @message = self.class.messages[code]
Severity: Minor
Found in lib/active_merchant/billing/avs_result.rb - About 35 mins to fix

Cognitive Complexity

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

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

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

Further reading

Avoid too many return statements within this method.
Open

          return response[:szAuthorizationDeclinedMessage]
Severity: Major
Found in lib/active_merchant/billing/gateways/skip_jack.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

              return base + 'vault/payment-instrument/token'
    Severity: Major
    Found in lib/active_merchant/billing/gateways/deepstack.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                return base + 'vault/token'
      Severity: Major
      Found in lib/active_merchant/billing/gateways/deepstack.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                  return base + 'noaction'
        Severity: Major
        Found in lib/active_merchant/billing/gateways/deepstack.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return response_code if response_code
          Severity: Major
          Found in lib/active_merchant/billing/gateways/payu_latam.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                      return base + 'payments/refund'
            Severity: Major
            Found in lib/active_merchant/billing/gateways/deepstack.rb - About 30 mins to fix

              Method add_invoice has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def add_invoice(post, money, options)
                      post[:amount] = localized_amount(money, options[:currency])
                      post[:reference] = options[:order_id]
                      post[:currency] = options[:currency] || currency(money)
                      if options[:descriptor_name] || options[:descriptor_city]
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/checkout_v2.rb - About 25 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Method acquire_access_token has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def acquire_access_token
                      post = {}
                      base_url = (test? ? test_url : live_url)
                      post[:grant_type] = 'password'
                      post[:username] = @options[:username]
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/pay_trace.rb - About 25 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Method amount has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def amount(money)
                      return nil if money.nil?
              
                      cents =
                        if money.respond_to?(:cents)
              Severity: Minor
              Found in lib/active_merchant/billing/gateway.rb - About 25 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Method build_request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def build_request(action, post, options = {})
                      mode = action == 'void' ? 'cancel' : 'get'
                      transaction_type = action == '3ds_preauth' ? '3DSAuthentication' : 'Authorization'
                      xml = Builder::XmlMarkup.new indent: 18
                      xml.instruct!(:xml, version: '1.0', encoding: 'utf-8')
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/borgun.rb - About 25 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

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

                    def post_data(params, use_profile_api)
                      params[:requestType] = 'BACKEND'
                      if use_profile_api
                        params[:merchantId] = @options[:login]
                        params[:passCode] = @options[:secure_profile_api_key]
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb - About 25 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Method error_code_from has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def error_code_from(action, response)
                      unless success_from(action, response)
                        if cause = response['cause']
                          cause.empty? ? nil : cause.first['code']
                        else
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/mercado_pago.rb - About 25 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Method hashify_address has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def hashify_address(address)
                      hash = {}
                      hash[:street1] = address[:address1] if address[:address1]
                      hash[:street2] = address[:address2] if address[:address2]
                      hash[:city] = address[:city] if address[:city]
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/cardprocess.rb - About 25 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Method check_token_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def check_token_response(response, endpoint, body = {}, options = {})
                      return response unless @options[:refresh_token]
                      return response unless options[:allow_refresh]
                      return response unless response.params['code'] == 'AuthenticationFailed'
              
              
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/quickbooks.rb - About 25 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Method add_three_d_secure has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def add_three_d_secure(post, options)
                      params = post[:parametros] ||= {}
                      return unless three_d_secure = options[:three_d_secure]
              
                      params[:exencionSCA] ||= CECA_SCA_TYPES.fetch(options[:exemption_type]&.to_sym, :NONE)
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/cecabank/cecabank_json.rb - About 25 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Method post has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def post(data, use_profile_api = nil)
                      response = parse(ssl_post((use_profile_api ? SECURE_PROFILE_URL : self.live_url), data))
                      response[:customer_vault_id] = response[:customerCode] if response[:customerCode]
                      build_response(
                        success?(response),
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb - About 25 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Method error_code_from has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def error_code_from(succeeded, response, options)
                      return if succeeded
              
                      if response['error_type'] && response['error_codes']
                        "#{response['error_type']}: #{response['error_codes'].join(', ')}"
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/checkout_v2.rb - About 25 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Method parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def parse(xml)
                      response = {}
              
                      doc = Nokogiri::XML(xml)
                      doc.xpath('//response/*').each do |node|
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/realex.rb - About 25 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Severity
              Category
              Status
              Source
              Language