activemerchant/active_merchant

View on GitHub

Showing 999 of 1,496 total issues

Method legacy_parse has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def legacy_parse(action, xml)
        response = {}

        error_messages = []
        error_codes = []
Severity: Minor
Found in lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb - About 1 hr to fix

    Method add_contact has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def add_contact(doc, fullname, options)
            doc['v1'].contact do
              doc['v1'].fullName fullname unless fullname.blank?
              doc['v1'].coName options[:company_name] if options[:company_name]
              doc['v1'].title options[:title] if options[:title]

      Method commit has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def commit(action, body, options, try_again = true)
              credentials = ensure_credentials
              payload = encrypt_payload(body, credentials, options)
      
              if options.dig :http, :method
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/alelo.rb - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

                if response['refusalReason'] && response['additionalData'] && (response['additionalData']['merchantAdviceCode'] || response['additionalData']['refusalReasonRaw'])
                  "#{response['refusalReason']} | #{response['additionalData']['merchantAdviceCode'] || response['additionalData']['refusalReasonRaw']}"
                else
                  response['refusalReason'] || response['resultCode'] || response['message'] || response['result']
                end
        Severity: Critical
        Found in lib/active_merchant/billing/gateways/adyen.rb - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                  if address = options[:billing_address] || options[:address]
                    post[:data][:attributes][:billingAddress] = {
                      line1: address[:address1] || '',
                      line2: address[:address2] || '',
                      city: address[:city] || '',
          Severity: Critical
          Found in lib/active_merchant/billing/gateways/digitzs.rb - About 1 hr to fix

            Method parse_cim has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def parse_cim(body, options)
                    response = {}
            
                    doc = Nokogiri::XML(body).remove_namespaces!
            
            
            Severity: Minor
            Found in lib/active_merchant/billing/gateways/authorize_net.rb - About 1 hr to fix

              Method parse has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def parse(data, action)
                      params  = {}
                      success = false
                      message = ''
                      options = @options.merge(test: test?)
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/redsys.rb - About 1 hr to fix

                Method build_purchase_request has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def build_purchase_request(money, payment_method_or_reference, options)
                        xml = Builder::XmlMarkup.new indent: 2
                        add_customer_id(xml, options)
                        add_payment_method_or_subscription(xml, money, payment_method_or_reference, options)
                        add_threeds_2_ucaf_data(xml, payment_method_or_reference, options)
                Severity: Minor
                Found in lib/active_merchant/billing/gateways/cyber_source.rb - About 1 hr to fix

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

                        def error_code_from(response)
                          unless success_from(response)
                            case response['result']['code']
                            when '100.100.101'
                              STANDARD_ERROR_CODE[:incorrect_number]
                  Severity: Minor
                  Found in lib/active_merchant/billing/gateways/cardprocess.rb - About 1 hr to fix

                    Method add_card_or_token_payment has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def add_card_or_token_payment(xml, card_or_token, options)
                            xml.hps :CardData do
                              if card_or_token.respond_to?(:number)
                                if card_or_token.track_data
                                  xml.tag!('hps:TrackData', 'method' => 'swipe') do
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/hps.rb - About 1 hr to fix

                      Method add_payment_method_id has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def add_payment_method_id(options)
                              return options[:payment_method_id].to_i if options[:payment_method_id]
                      
                              if options[:debit]
                                case options[:card_brand]
                      Severity: Minor
                      Found in lib/active_merchant/billing/gateways/decidir_plus.rb - About 1 hr to fix

                        Method commit has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              def commit(action, parameters, method = 'POST')
                                url = (test? ? test_url : live_url)
                                if no_hmac(action)
                                  request_headers = headers.merge(create_basic(parameters, action))
                                else
                        Severity: Minor
                        Found in lib/active_merchant/billing/gateways/deepstack.rb - About 1 hr to fix

                          Method add_three_ds_fields has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def add_three_ds_fields(post, three_ds_options)
                                  three_ds = {}
                                  three_ds[:version] = three_ds_options[:version] if three_ds_options[:version]
                                  three_ds[:eci] = three_ds_options[:eci] if three_ds_options[:eci]
                                  three_ds[:cavv] = three_ds_options[:cavv] if three_ds_options[:cavv]
                          Severity: Minor
                          Found in lib/active_merchant/billing/gateways/simetrik.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 list has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def self.list
                              hosts = Set.new
                              invalid_lines = Set.new
                          
                              Dir['lib/**/*.rb'].each do |file|
                          Severity: Minor
                          Found in lib/support/outbound_hosts.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 purchase has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def purchase(money, payment_or_customer_id, options = {})
                                  if visa_or_mastercard?(options)
                                    MultiResponse.run(:use_first_response) do |r|
                                      endpoint = customer_id?(payment_or_customer_id) ? ENDPOINTS[:customer_id_sale] : ENDPOINTS[:keyed_sale]
                          
                          
                          Severity: Minor
                          Found in lib/active_merchant/billing/gateways/pay_trace.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 perform_request has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def perform_request(action, post, options, authorization = nil, method = :post)
                                  begin
                                    raw_response = ssl_request(method, url(action, authorization), post.nil? || post.empty? ? nil : post.to_json, headers(action, options))
                                    response = parse(raw_response)
                                    response['id'] = response['_links']['payment']['href'].split('/')[-1] if action == :capture && response.key?('_links')
                          Severity: Minor
                          Found in lib/active_merchant/billing/gateways/checkout_v2.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 localized_amount has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def localized_amount(money, currency)
                                  amount = amount(money)
                          
                                  return amount unless non_fractional_currency?(currency) || three_decimal_currency?(currency)
                          
                          
                          Severity: Minor
                          Found in lib/active_merchant/billing/gateway.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_credentials has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def add_stored_credentials(post, creditcard, options)
                                  return unless stored_credential = options[:stored_credential]
                          
                                  return if options[:exemption_type].blank? && !(stored_credential[:reason_type] && stored_credential[:initiator])
                          
                          
                          Severity: Minor
                          Found in lib/active_merchant/billing/gateways/cecabank/cecabank_json.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 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def add_address(post, options)
                                  return unless post[:card]&.kind_of?(Hash)
                          
                                  card_address = {}
                                  if address = options[:billing_address] || options[:address]
                          Severity: Minor
                          Found in lib/active_merchant/billing/gateways/quickbooks.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_merchant_data has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def add_merchant_data(doc, options = {})
                                  if options[:affiliate] || options[:campaign] || options[:merchant_grouping_id]
                                    doc.merchantData do
                                      doc.affiliate(options[:affiliate]) if options[:affiliate]
                                      doc.campaign(options[:campaign]) if options[:campaign]
                          Severity: Minor
                          Found in lib/active_merchant/billing/gateways/litle.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