activemerchant/active_merchant

View on GitHub

Showing 1,501 of 1,501 total issues

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

      def purchase(amount, payment, options = {})
        post = PostData.new
        add_invoice(post, amount, options)
        add_payment(post, payment)
        add_address(post, payment, options)
Severity: Major
Found in lib/active_merchant/billing/gateways/transact_pro.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/transact_pro.rb on lines 47..64

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

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

      STANDARD_ERROR_CODE_MAPPING = {
        'incorrect_number' => STANDARD_ERROR_CODE[:incorrect_number],
        'invalid_number' => STANDARD_ERROR_CODE[:invalid_number],
        'invalid_expiry_month' => STANDARD_ERROR_CODE[:invalid_expiry_date],
        'invalid_expiry_year' => STANDARD_ERROR_CODE[:invalid_expiry_date],
Severity: Major
Found in lib/active_merchant/billing/gateways/stripe.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/quickbooks.rb on lines 20..45

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

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_CustomerCreditCardAuth(xml, money, parameters)
        cc = parameters[:credit_card]
        name = "#{cc.first_name} #{cc.last_name}"[0...30]

        xml.tag!('TransRequestID', parameters[:trans_request_id])
Severity: Major
Found in lib/active_merchant/billing/gateways/qbms.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/qbms.rb on lines 246..258

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

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

          xml.BillingAddress {
            xml.FirstName(payment_source.first_name || parse_first_name(billing_address[:name]))
            xml.LastName(payment_source.last_name || parse_last_name(billing_address[:name]))
            xml.Address1(billing_address[:address1])
            xml.Address2(billing_address[:address2]) unless billing_address[:address2].blank?
Severity: Major
Found in lib/active_merchant/billing/gateways/itransact.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/itransact.rb on lines 287..296

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

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

          xml.ShippingAddress {
            xml.FirstName(payment_source.first_name || parse_first_name(shipping_address[:name]))
            xml.LastName(payment_source.last_name || parse_last_name(shipping_address[:name]))
            xml.Address1(shipping_address[:address1])
            xml.Address2(shipping_address[:address2]) unless shipping_address[:address2].blank?
Severity: Major
Found in lib/active_merchant/billing/gateways/itransact.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/itransact.rb on lines 276..285

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

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

      STANDARD_ERROR_CODE_MAPPING = {
        # Fraud Warnings
        'PMT-1000' => STANDARD_ERROR_CODE[:processing_error],   # payment was accepted, but refund was unsuccessful
        'PMT-1001' => STANDARD_ERROR_CODE[:invalid_cvc],        # payment processed, but cvc was invalid
        'PMT-1002' => STANDARD_ERROR_CODE[:incorrect_address],  # payment processed, incorrect address info
Severity: Major
Found in lib/active_merchant/billing/gateways/quickbooks.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/stripe.rb on lines 39..54

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

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_CustomerCreditCardCharge(xml, money, parameters)
        cc = parameters[:credit_card]
        name = "#{cc.first_name} #{cc.last_name}"[0...30]

        xml.tag!('TransRequestID', parameters[:trans_request_id])
Severity: Major
Found in lib/active_merchant/billing/gateways/qbms.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/gateways/qbms.rb on lines 225..237

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

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_transaction has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def add_transaction(xml, transaction)
        raise StandardError, "Invalid Customer Information Manager Transaction Type: #{transaction[:type]}" unless CIM_TRANSACTION_TYPES.include?(transaction[:type])

        xml.tag!('transaction') do
          xml.tag!(CIM_TRANSACTION_TYPES[transaction[:type]]) do
Severity: Minor
Found in lib/active_merchant/billing/gateways/authorize_net_cim.rb - About 1 hr to fix

    Method verify has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def verify(creditcard, options = {})
            if options[:allow_card_verification] == true
              options.delete(:allow_card_verification)
              exp_month = creditcard.month.to_s
              exp_year = creditcard.year.to_s
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/braintree_blue.rb - About 1 hr to fix

      Method test_gateways has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def test_gateways(min_version = :TLS1_1)
          raise 'Requires Ruby 2.5 or better' unless Net::HTTP.instance_methods.include?(:min_version=)
      
          puts "Verifying #{@gateways.count} gateways for SSL min_version=#{min_version}\n\n"
      
      
      Severity: Minor
      Found in lib/support/ssl_version.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 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_address(tag, post, options)
              return unless address_options = options[:shipping_address]
      
              address = {}
              address[:name] = address_options[:name] if address_options[:name]
      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 add_level_3_data has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_level_3_data(post, options)
              post[:invoice_id] = options[:invoice_id] if options[:invoice_id]
              post[:customer_reference_id] = options[:customer_reference_id] if options[:customer_reference_id]
              post[:tax_amount] = options[:tax_amount].to_i if options[:tax_amount]
              post[:national_tax_amount] = options[:national_tax_amount].to_i if options[:national_tax_amount]
      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 requires! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def requires!(hash, *params)
              params.each do |param|
                if param.is_a?(Array)
                  raise ArgumentError.new("Missing required parameter: #{param.first}") unless hash.has_key?(param.first)
      
      
      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 commit has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def commit(action, parameters)
              parameters[:request] = action
      
              url = (test? ? test_url : live_url)
              payload = parameters.to_json unless parameters.nil?
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/payway_dot_com.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 commit has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def commit(action, parameters)
              if action == 'void'
                commit_raw(action, parameters)
              else
                MultiResponse.run(true) do |r|
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/ct_payment.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 parse_response has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse_response(response, root)
              status = nil
      
              root.elements.to_a.each do |node|
                status = REXML::XPath.first(node, 'CC_TRANSACTION/PROCESSING_STATUS') if node.name =~ /FNC_CC_/
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/wirecard.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_credit_card has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_credit_card(xml, credit_card, action)
              xml.tag! 'Account' do
                if credit_card.track_data.present?
                  # Track 1 has a start sentinel (STX) of '%' and track 2 is ';'
                  # Track 1 and 2 have identical end sentinels (ETX) of '?'
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/mercury.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_transaction_data has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_transaction_data(xml, money, options)
              options[:order_id] ||= generate_unique_id
      
              xml.tag! "FNC_CC_#{options[:action].to_s.upcase}" do
                xml.tag! 'FunctionID', clean_description(options[:description])
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/wirecard.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 commit has a Cognitive Complexity of 12 (exceeds 5 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

      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 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_network_tokenization_card(xml, payment_method, options)
              source = payment_method.respond_to?(:source) ? payment_method.source : options[:wallet_type]
              token_type = NETWORK_TOKEN_TYPE.fetch(source, 'NETWORKTOKEN')
      
              xml.paymentDetails do
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/worldpay.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