activemerchant/active_merchant

View on GitHub

Showing 1,501 of 1,501 total issues

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

      def ensure_credentials(try_again = true)
        multiresp = MultiResponse.new
        access_token = @options[:access_token]
        key = @options[:encryption_key]
        uuid = @options[:encryption_uuid]
Severity: Minor
Found in lib/active_merchant/billing/gateways/alelo.rb - About 1 hr to fix

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

          def add_customer_data(xml, payment_source, options)
            billing_address = options[:billing_address] || options[:address]
            shipping_address = options[:shipping_address] || options[:address]
    
            xml.CustomerData {
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/itransact.rb - About 1 hr to fix

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

            def commit(action, post)
              post[:MerchantId] = @options[:merchant_id]
              post[:Password] = @options[:password]
              post[:UserId] = @options[:user_id]
              post[:TransactionType] = action
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/cenpos.rb - About 1 hr to fix

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

              def build_customer_request_xml(credit_card, options = {})
                ActiveMerchant.deprecated 'Customer Profile support in Orbital is non-conformant to the ActiveMerchant API and will be removed in its current form in a future version. Please contact the ActiveMerchant maintainers if you have an interest in modifying it to conform to the store/unstore/update API.'
                xml = xml_envelope
                xml.tag! :Request do
                  xml.tag! :Profile do
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/orbital.rb - About 1 hr to fix

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

                def message_from(results)
                  if results[:response_code] == DECLINED
                    return CVVResult.messages[results[:card_code]] if CARD_CODE_ERRORS.include?(results[:card_code])
                    return AVSResult.messages[results[:avs_result_code]] if AVS_REASON_CODES.include?(results[:response_reason_code]) && AVS_ERRORS.include?(results[:avs_result_code])
                  end
          Severity: Major
          Found in lib/active_merchant/billing/gateways/secure_pay.rb and 1 other location - About 1 hr to fix
          lib/active_merchant/billing/gateways/metrics_global.rb on lines 281..287

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

          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 purchase_emv(money, paysource, options = {})
                  money = amount(money)
                  case money
                  when /00$/
                    Response.new(true, SUCCESS_MESSAGE, { paid_amount: money }, test: true, authorization: AUTHORIZATION, emv_authorization: AUTHORIZATION_EMV_SUCCESS)
          Severity: Major
          Found in lib/active_merchant/billing/gateways/bogus.rb and 1 other location - About 1 hr to fix
          lib/active_merchant/billing/gateways/bogus.rb on lines 121..129

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

          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

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

                def add_creditcard(post, creditcard, options)
                  if options[:store]
                    post[:customer_vault] = 'add_customer'
                    post[:customer_vault_id] = options[:store] unless options[:store] == true
                  end
          Severity: Major
          Found in lib/active_merchant/billing/gateways/inspire.rb and 1 other location - About 1 hr to fix
          lib/active_merchant/billing/gateways/smart_ps.rb on lines 178..187

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

          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

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

                def add_creditcard(post, creditcard, options)
                  if options[:store]
                    post[:customer_vault] = 'add_customer'
                    post[:customer_vault_id] = options[:store] unless options[:store] == true
                  end
          Severity: Major
          Found in lib/active_merchant/billing/gateways/smart_ps.rb and 1 other location - About 1 hr to fix
          lib/active_merchant/billing/gateways/inspire.rb on lines 139..148

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

          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

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

                def message_from(results)
                  if results[:response_code] == DECLINED
                    return CVVResult.messages[results[:card_code]] if CARD_CODE_ERRORS.include?(results[:card_code])
                    return AVSResult.messages[results[:avs_result_code]] if AVS_REASON_CODES.include?(results[:response_reason_code]) && AVS_ERRORS.include?(results[:avs_result_code])
                  end
          Severity: Major
          Found in lib/active_merchant/billing/gateways/metrics_global.rb and 1 other location - About 1 hr to fix
          lib/active_merchant/billing/gateways/secure_pay.rb on lines 179..185

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

          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 authorize_emv(money, paysource, options = {})
                  money = amount(money)
                  case money
                  when /00$/
                    Response.new(true, SUCCESS_MESSAGE, { authorized_amount: money }, test: true, authorization: AUTHORIZATION, emv_authorization: AUTHORIZATION_EMV_SUCCESS)
          Severity: Major
          Found in lib/active_merchant/billing/gateways/bogus.rb and 1 other location - About 1 hr to fix
          lib/active_merchant/billing/gateways/bogus.rb on lines 145..153

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

          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_forward_payload has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def add_forward_payload(post, money, payment, options)
                  forward_payload = {}
                  add_user(forward_payload, options[:user]) if options[:user]
                  add_order(forward_payload, money, options)
                  add_payment_method(forward_payload, payment, options[:payment_method]) if options[:payment_method] || payment
          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 retry_network_exceptions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def retry_network_exceptions(options = {})
                initial_retries = options[:max_retries] || DEFAULT_RETRIES
                retries = initial_retries
                request_start = nil
          
          
          Severity: Minor
          Found in lib/active_merchant/network_connection_retries.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 success_from has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def success_from(action, response)
                  return response['status'] == 'Pending' if action == :credit
                  return true if action == :unstore && response == 204
          
                  store_response = response['token'] || response['id']
          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 configure_ssl has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def configure_ssl(http)
                return unless endpoint.scheme == 'https'
          
                http.use_ssl = true
                http.ssl_version = ssl_version if ssl_version
          Severity: Minor
          Found in lib/active_merchant/connection.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 prepare_address_for_non_american_countries has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def prepare_address_for_non_american_countries(options)
                  [options[:billing_address], options[:shipping_address]].compact.each do |address|
                    next if empty?(address[:country])
          
                    unless %w[US CA].include?(address[:country])
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/beanstream/beanstream_core.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 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def add_address(post, payment, options)
                  post[:cardAccount] ||= {}
                  address = options[:billing_address] || options[:address] || {}
                  first_name, last_name = split_names(address[:name])
                  full_address = "#{address[:address1]} #{address[:address2]}".strip
          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 add_payer has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def add_payer(post, card, options)
                  address = options[:billing_address] || options[:address]
                  phone_number = address[:phone] || address[:phone_number] if address
          
                  post[:payer] = {}
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/d_local.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_additional_verification has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def add_additional_verification(xml, options)
                  return unless (options[:verify_zip].to_s == 'true') || (options[:verify_address].to_s == 'true')
          
                  if address = options[:billing_address]
                    xml.AdditionalVerification do
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/creditcall.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 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def add_customer_data(post, payment_method, options)
                  billing = {}
                  shipping = {}
                  customer = {}
                  device = {}
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/mastercard.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_creditcard has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def add_creditcard(post, creditcard, options)
                  card = {}
                  if creditcard.respond_to?(:number)
                    card[:number] = creditcard.number
                    card[:expMonth] = creditcard.month
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/securion_pay.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