activemerchant/active_merchant

View on GitHub

Showing 1,005 of 1,501 total issues

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

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

      def add_shipping_contact_info(doc, payment_method, options)
        if address = options[:shipping_address]
          # https://developers.bluesnap.com/v8976-XML/docs/shipping-contact-info
          doc.send('first-name', payment_method.first_name)
          doc.send('last-name', payment_method.last_name)
Severity: Minor
Found in lib/active_merchant/billing/gateways/blue_snap.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 create_intent has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def create_intent(money, payment_method, options = {})
        MultiResponse.run do |r|
          if payment_method.is_a?(NetworkTokenizationCreditCard) && digital_wallet_payment_method?(payment_method) && options[:new_ap_gp_route] != true
            r.process { tokenize_apple_google(payment_method, options) }
            payment_method = (r.params['token']['id']) if r.success?
Severity: Minor
Found in lib/active_merchant/billing/gateways/stripe_payment_intents.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 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/balanced.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 14 (exceeds 5 allowed). Consider refactoring.
Open

      def add_payment(xml, money, payment, options)
        requires!(options.merge!({ money: money }), :currency, :money)
        xml.tag!('v1:Payment') do
          xml.tag!('v1:HostedDataID', payment) if payment&.is_a?(String)
          xml.tag!('v1:HostedDataStoreID', options[:hosted_data_store_id]) if options[:hosted_data_store_id]
Severity: Minor
Found in lib/active_merchant/billing/gateways/ipg.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_installments has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def add_installments(xml, options)
        return unless %i[installment_total_count installment_total_amount installment_plan_type first_installment_date installment_annual_interest_rate installment_grace_period_duration].any? { |gsf| options.include?(gsf) }

        xml.tag! 'installment' do
          xml.tag!('totalCount', options[:installment_total_count]) if options[:installment_total_count]
Severity: Minor
Found in lib/active_merchant/billing/gateways/cyber_source.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 request has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def request(method, body, headers = {})
      request_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)

      headers = headers.dup
      headers['connection'] ||= 'close'
Severity: Minor
Found in lib/active_merchant/connection.rb - About 1 hr to fix

    Method add_creditcard has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def add_creditcard(post, creditcard, options, use_sources = false)
            card = {}
            if emv_payment?(creditcard)
              add_emv_creditcard(post, creditcard.icc_data)
              post[:card][:read_method] = 'contactless' if creditcard.read_method == 'contactless'
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/stripe.rb - About 1 hr to fix

      Method test_gateways has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def test_gateways
          success, failed, missing, errored, disabled = [], [], [], [], []
      
          puts "Verifying #{@gateways.count} SSL certificates\n\n"
      
      
      Severity: Minor
      Found in lib/support/ssl_verify.rb - About 1 hr to fix

        Method scrub has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def scrub(transcript)
                ret_transcript = transcript
                auth_origin = ret_transcript[/<authorization>(.*?)<\/authorization>/, 1]
                unless auth_origin.nil?
                  auth_origin = auth_origin.gsub('\n', '')
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/mit.rb - About 1 hr to fix

          Method create_intent has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def create_intent(money, payment_method, options = {})
                  MultiResponse.run do |r|
                    if payment_method.is_a?(NetworkTokenizationCreditCard) && digital_wallet_payment_method?(payment_method) && options[:new_ap_gp_route] != true
                      r.process { tokenize_apple_google(payment_method, options) }
                      payment_method = (r.params['token']['id']) if r.success?
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/stripe_payment_intents.rb - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                    return unless options[:merchant_descriptor] ||
                                  options[:user_po] ||
                                  options[:taxable] ||
                                  options[:reference_data_code] ||
                                  options[:invoice_number] ||
            Severity: Critical
            Found in lib/active_merchant/billing/gateways/cyber_source.rb - About 1 hr to fix

              Method build_recurring_request has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def build_recurring_request(action, money, options)
                      raise StandardError, "Invalid Recurring Profile Action: #{action}" unless RECURRING_ACTIONS.include?(action)
              
                      xml = Builder::XmlMarkup.new
                      xml.tag! 'RecurringProfiles' do
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/payflow.rb - About 1 hr to fix

                Method add_aft_data has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def add_aft_data(xml, payment_method, options)
                        xml.fundingTransfer 'type' => options[:aft_type], 'category' => 'PULL_FROM_CARD' do
                          xml.paymentPurpose options[:aft_payment_purpose] # Must be included for the recipient for following countries, otherwise optional: Argentina, Bangladesh, Chile, Columbia, Jordan, Mexico, Thailand, UAE, India cross-border
                          xml.fundingParty 'type' => 'sender' do
                            xml.accountReference options[:aft_sender_account_reference], 'accountType' => options[:aft_sender_account_type]
                Severity: Minor
                Found in lib/active_merchant/billing/gateways/worldpay.rb - About 1 hr to fix

                  Method parse_element has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def parse_element(reply, node)
                          case node.name
                          when 'CrossReferenceTransactionResult'
                            reply[:transaction_result] = {}
                            node.attributes.each do |a, b|
                  Severity: Minor
                  Found in lib/active_merchant/billing/gateways/iridium.rb - About 1 hr to fix

                    Method create_transaction_parameters has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def create_transaction_parameters(money, credit_card_or_vault_id, options)
                            parameters = {
                              amount: localized_amount(money, options[:currency] || default_currency).to_s,
                              order_id: options[:order_id],
                              customer: {
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/braintree_blue.rb - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language