activemerchant/active_merchant

View on GitHub

Showing 1,501 of 1,501 total issues

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

      def add_customer_data(post, options, payment = nil)
        if payment
          post['order']['customer']['personalInformation']['name']['firstName'] = payment.first_name[0..14] if payment.first_name
          post['order']['customer']['personalInformation']['name']['surname'] = payment.last_name[0..69] if payment.last_name
        end
Severity: Minor
Found in lib/active_merchant/billing/gateways/global_collect.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_token_info has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def add_network_token_info(post, payment_method, options)
        # wallet_type is only passed for non-tokenized GooglePay which acts as a CreditCard
        if options[:wallet_type]
          post[:metadata] ||= {}
          post[:metadata][:input_method] = 'GooglePay'
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 add_customer_with_credit_card has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def add_customer_with_credit_card(creditcard, options)
        commit do
          if options[:payment_method_nonce]
            credit_card_params = { payment_method_nonce: options[:payment_method_nonce] }
          else
Severity: Minor
Found in lib/active_merchant/billing/gateways/braintree_blue.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_credential_data has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def add_stored_credential_data(post, payment_method, options)
        post['order.ECI'] = options[:eci] || eci(options)
        if (stored_credential = options[:stored_credential]) && %w(visa master).include?(payment_method.brand)
          post['card.posEntryMode'] = stored_credential[:initial_transaction] ? 'MANUAL' : 'STORED_CREDENTIAL'
          stored_credential_usage(post, payment_method, options) unless stored_credential[:initiator] && stored_credential[:initiator] == 'cardholder'
Severity: Minor
Found in lib/active_merchant/billing/gateways/qvalent.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_credential_transaction_type has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def add_stored_credential_transaction_type(post, options = {})
        return unless options[:stored_credential_transaction_type]

        stored_credential = options[:stored_credential]
        # Do not add anything unless these are present.
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 add_address has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def add_address(post, address, prefix = '')
        prefix += '_' unless prefix.blank?
        unless address.blank? || address.values.blank?
          post[prefix + 'address1']    = address[:address1].to_s
          post[prefix + 'address2']    = address[:address2].to_s unless address[:address2].blank?
Severity: Minor
Found in lib/active_merchant/billing/gateways/smart_ps.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_purchase_data has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def add_purchase_data(xml, money = 0, include_grand_total = false, options = {})
        xml.tag! 'purchaseTotals' do
          xml.tag! 'currency', options[:currency] || currency(money)
          xml.tag!('discountManagementIndicator', options[:discount_management_indicator]) if options[:discount_management_indicator]
          xml.tag!('taxAmount', options[:purchase_tax_amount]) if options[:purchase_tax_amount]
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 add_managed_billing has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def add_managed_billing(xml, options)
        return unless mb = options[:managed_billing]

        ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE

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

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

          post[:shipping_firstname]   = address[:first_name]
          post[:shipping_lastname]    = address[:last_name]
          post[:shipping_address1]    = address[:address1]
          post[:shipping_address2]    = address[:address2]
          post[:shipping_company]     = address[:company]
Severity: Major
Found in lib/active_merchant/billing/gateways/evo_ca.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/verifi.rb on lines 130..138

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 55.

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 build_shipping_address(soap, options)
        if options[:shipping_address]
          options[:shipping_address][:first_name], options[:shipping_address][:last_name] = split_names(options[:shipping_address][:name]) if options[:shipping_address][:name]
          soap.ShippingAddress 'xsi:type' => 'ns1:Address' do
            ADDRESS_OPTIONS.each do |k, v|
Severity: Major
Found in lib/active_merchant/billing/gateways/usa_epay_advanced.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/usa_epay_advanced.rb on lines 1474..1479

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 55.

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 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

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

      def build_billing_address(soap, options)
        if options[:billing_address]
          options[:billing_address][:first_name], options[:billing_address][:last_name] = split_names(options[:billing_address][:name]) if options[:billing_address][:name]
          soap.BillingAddress 'xsi:type' => 'ns1:Address' do
            ADDRESS_OPTIONS.each do |k, v|
Severity: Major
Found in lib/active_merchant/billing/gateways/usa_epay_advanced.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/usa_epay_advanced.rb on lines 1485..1490

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 55.

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

          post[:company]    = billing_address[:company]
          post[:address1]   = billing_address[:address1]
          post[:address2]   = billing_address[:address2]
          post[:city]       = billing_address[:city]
          post[:state]      = billing_address[:state]
Severity: Major
Found in lib/active_merchant/billing/gateways/verifi.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/evo_ca.rb on lines 222..230

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 55.

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 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

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

                        if value.is_a?(Hash)
                          h = {}
                          value.each do |k, v|
                            h["#{key}[#{k}]"] = v unless v.blank?
                          end
              Severity: Major
              Found in lib/active_merchant/billing/gateways/pagarme.rb and 1 other location - About 1 hr to fix
              lib/active_merchant/billing/gateways/securion_pay.rb on lines 272..282

              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 54.

              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

              Severity
              Category
              Status
              Source
              Language