activemerchant/active_merchant

View on GitHub

Showing 1,005 of 1,501 total issues

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

      def add_level3_purchase(xml, options = {})
        if (level3 = options[:level_3_data])
          xml.tag! :PC3FreightAmt,    byte_limit(level3[:freight_amount], 12) if level3[:freight_amount]
          xml.tag! :PC3DutyAmt,       byte_limit(level3[:duty_amount], 12) if level3[:duty_amount]
          xml.tag! :PC3DestCountryCd, byte_limit(level3[:dest_country], 3) if level3[:dest_country]
Severity: Minor
Found in lib/active_merchant/billing/gateways/orbital.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 recurring has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def recurring(money, payment_source, options = {})
        ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE

        requires!(options, %i[periodicity monthly weekly daily], :payments)

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

    Method normal_refund has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def normal_refund(amount, authorization, options)
            transaction_id, card_number, = split_authorization(authorization)
    
            commit(:refund) do |xml|
              xml.transactionRequest do
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/authorize_net.rb - About 1 hr to fix

      Method build_request has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def build_request(action)
              xml = Builder::XmlMarkup.new(encoding: 'UTF-8')
              xml.instruct!(:xml, encoding: 'UTF-8')
              xml.SOAP :Envelope, {
                'xmlns:SOAP' => 'http://schemas.xmlsoap.org/soap/envelope/',
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/hps.rb - About 1 hr to fix

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

              def parse(body)
                reply = {}
                xml = REXML::Document.new(body)
                if root = REXML::XPath.first(xml, '//soap:Fault') then
                  reply = parse_fault(root)
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/eway_managed.rb - About 1 hr to fix

          Method build_change_profile_request has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def build_change_profile_request(profile_id, options)
                  xml = Builder::XmlMarkup.new :indent => 2
                  xml.tag! 'UpdateRecurringPaymentsProfileReq', 'xmlns' => PAYPAL_NAMESPACE do
                    xml.tag! 'UpdateRecurringPaymentsProfileRequest', 'xmlns:n2' => EBAY_NAMESPACE do
                      xml.tag! 'n2:Version', API_VERSION
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb - About 1 hr to fix

            Method build_request has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def build_request(payment_code, money, payment, options)
                    xml = Builder::XmlMarkup.new indent: 2
                    xml.instruct!
                    xml.tag! 'Request', 'version' => API_VERSION do
                      xml.tag! 'Header' do
            Severity: Minor
            Found in lib/active_merchant/billing/gateways/axcessms.rb - About 1 hr to fix

              Method build_credit_card_request has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def build_credit_card_request(action, money, credit_card, options)
                      xml = Builder::XmlMarkup.new
                      xml.tag! TRANSACTIONS[action] do
                        xml.tag! 'PayData' do
                          xml.tag! 'Invoice' do
              Severity: Minor
              Found in lib/active_merchant/billing/gateways/payflow.rb - About 1 hr to fix

                Method build_reference_sale_or_authorization_request has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def build_reference_sale_or_authorization_request(action, money, reference, options)
                        xml = Builder::XmlMarkup.new
                        xml.tag! TRANSACTIONS[action] do
                          xml.tag! 'PayData' do
                            xml.tag! 'Invoice' do
                Severity: Minor
                Found in lib/active_merchant/billing/gateways/payflow.rb - About 1 hr to fix

                  Method credit has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def credit(money, creditcard, options = {})
                          post = payment_request(money, options)
                          post[:amount] = amount_hash(money, options[:currency])
                          post[:card] = credit_card_hash(creditcard)
                          post[:dateOfBirth] = options[:date_of_birth] if options[:date_of_birth]
                  Severity: Minor
                  Found in lib/active_merchant/billing/gateways/barclaycard_smartpay.rb - About 1 hr to fix

                    Method store has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def store(payment, options = {})
                            params = {}
                            post = {}
                    
                            if payment.is_a?(ApplePayPaymentToken)
                    Severity: Minor
                    Found in lib/active_merchant/billing/gateways/stripe.rb - About 1 hr to fix

                      Method add_auth_wallet has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def add_auth_wallet(xml, payment_method, options)
                              commerce_indicator = 'internet' if subsequent_nt_apple_pay_auth(payment_method.source, options)
                      
                              brand = card_brand(payment_method).to_sym
                      
                      
                      Severity: Minor
                      Found in lib/active_merchant/billing/gateways/cyber_source.rb - About 1 hr to fix

                        Method add_addresses has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              def add_addresses(post, options)
                                if address = options[:billing_address] || options[:address]
                                  post[:card_address1] = address[:address1]
                                  post[:card_zip]      = address[:zip]
                                  post[:card_city]     = address[:city]
                        Severity: Minor
                        Found in lib/active_merchant/billing/gateways/plugnpay.rb - About 1 hr to fix

                          Method soap_request has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                def soap_request(arguments, action)
                                  # eWay demands all fields be sent, but contain an empty string if blank
                                  post = case action
                                         when 'QueryCustomer'
                                           arguments
                          Severity: Minor
                          Found in lib/active_merchant/billing/gateways/eway_managed.rb - About 1 hr to fix

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

                                  def parse(action, soap)
                                    xml = REXML::Document.new(soap)
                                    root = REXML::XPath.first(xml, '//SOAP-ENV:Body')
                                    response = root ? parse_element(root[0]) : { response: soap }
                            
                            
                            Severity: Minor
                            Found in lib/active_merchant/billing/gateways/usa_epay_advanced.rb - About 1 hr to fix

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

                                    def commit(action, money, parameters)
                                      case action
                                      when 'sale'
                                        begin
                                          response = call_api(TRANSACTION_API, parameters)
                              Severity: Minor
                              Found in lib/active_merchant/billing/gateways/swipe_checkout.rb - About 1 hr to fix

                                Method update has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                      def update(vault_id, creditcard, options = {})
                                        braintree_credit_card = nil
                                        commit do
                                          braintree_credit_card = @braintree_gateway.customer.find(vault_id).credit_cards.detect(&:default?)
                                          return Response.new(false, 'Braintree::NotFoundError') if braintree_credit_card.nil?
                                Severity: Minor
                                Found in lib/active_merchant/billing/gateways/braintree_blue.rb - About 1 hr to fix

                                  Method build_create_subscription_request has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                        def build_create_subscription_request(payment_method, options)
                                          default_subscription_params = { frequency: 'on-demand', amount: 0, automatic_renew: false }
                                          options[:subscription] = default_subscription_params.update(
                                            options[:subscription] || {}
                                          )
                                  Severity: Minor
                                  Found in lib/active_merchant/billing/gateways/cyber_source.rb - About 1 hr to fix

                                    Method add_pay_data has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                          def add_pay_data(xml, money, options)
                                            xml.tag! 'PayData' do
                                              xml.tag! 'Invoice' do
                                                xml.tag! 'CustIP', options[:ip] unless options[:ip].blank?
                                                xml.tag! 'InvNum', options[:order_id] unless options[:order_id].blank?
                                    Severity: Minor
                                    Found in lib/active_merchant/billing/gateways/payflow_express.rb - About 1 hr to fix

                                      Method add_payout_sender_data has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                            def add_payout_sender_data(post, options)
                                              return unless options[:payout] == true
                                      
                                              post[:sender] = {
                                                # options for type are individual, corporate, or government
                                      Severity: Minor
                                      Found in lib/active_merchant/billing/gateways/checkout_v2.rb - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language