activemerchant/active_merchant

View on GitHub

Showing 1,501 of 1,501 total issues

Method build_recurring_request has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def build_recurring_request(action, money, options)
        raise StandardError, "Invalid Recurring Profile Action: #{action}" unless RECURRING_ACTIONS.include?(action)

        xml = Builder::XmlMarkup.new
        xml.tag! 'RecurringProfiles' do
Severity: Minor
Found in lib/active_merchant/billing/gateways/payflow.rb - About 1 hr to fix

    Method add_aft_data has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def add_aft_data(xml, payment_method, options)
            xml.fundingTransfer 'type' => options[:aft_type], 'category' => 'PULL_FROM_CARD' do
              xml.paymentPurpose options[:aft_payment_purpose] # Must be included for the recipient for following countries, otherwise optional: Argentina, Bangladesh, Chile, Columbia, Jordan, Mexico, Thailand, UAE, India cross-border
              xml.fundingParty 'type' => 'sender' do
                xml.accountReference options[:aft_sender_account_reference], 'accountType' => options[:aft_sender_account_type]
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/worldpay.rb - About 1 hr to fix

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

            STANDARD_ERROR_CODE_MAPPING = {
              # Bank error codes: https://support.payeezy.com/hc/en-us/articles/203730509-First-Data-Global-Gateway-e4-Bank-Response-Codes
              '201' => STANDARD_ERROR_CODE[:incorrect_number],
              '531' => STANDARD_ERROR_CODE[:invalid_cvc],
              '503' => STANDARD_ERROR_CODE[:invalid_cvc],
      Severity: Major
      Found in lib/active_merchant/billing/gateways/firstdata_e4_v27.rb and 3 other locations - About 1 hr to fix
      lib/active_merchant/billing/gateways/firstdata_e4.rb on lines 45..63
      lib/active_merchant/billing/gateways/pay_hub.rb on lines 50..66
      lib/active_merchant/billing/gateways/usa_epay_transaction.rb on lines 23..39

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

      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 4 locations. Consider refactoring.
      Open

            STANDARD_ERROR_CODE_MAPPING = {
              '00011' => STANDARD_ERROR_CODE[:incorrect_number],
              '00012' => STANDARD_ERROR_CODE[:incorrect_number],
              '00013' => STANDARD_ERROR_CODE[:incorrect_number],
              '00014' => STANDARD_ERROR_CODE[:invalid_number],
      lib/active_merchant/billing/gateways/firstdata_e4.rb on lines 45..63
      lib/active_merchant/billing/gateways/firstdata_e4_v27.rb on lines 37..55
      lib/active_merchant/billing/gateways/pay_hub.rb on lines 50..66

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

      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 4 locations. Consider refactoring.
      Open

            STANDARD_ERROR_CODE_MAPPING = {
              # Bank error codes: https://firstdata.zendesk.com/entries/471297-First-Data-Global-Gateway-e4-Bank-Response-Codes
              '201' => STANDARD_ERROR_CODE[:incorrect_number],
              '531' => STANDARD_ERROR_CODE[:invalid_cvc],
              '503' => STANDARD_ERROR_CODE[:invalid_cvc],
      Severity: Major
      Found in lib/active_merchant/billing/gateways/firstdata_e4.rb and 3 other locations - About 1 hr to fix
      lib/active_merchant/billing/gateways/firstdata_e4_v27.rb on lines 37..55
      lib/active_merchant/billing/gateways/pay_hub.rb on lines 50..66
      lib/active_merchant/billing/gateways/usa_epay_transaction.rb on lines 23..39

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

      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 4 locations. Consider refactoring.
      Open

            STANDARD_ERROR_CODE_MAPPING = {
              '14' => STANDARD_ERROR_CODE[:invalid_number],
              '80' => STANDARD_ERROR_CODE[:invalid_expiry_date],
              '82' => STANDARD_ERROR_CODE[:invalid_cvc],
              '54' => STANDARD_ERROR_CODE[:expired_card],
      Severity: Major
      Found in lib/active_merchant/billing/gateways/pay_hub.rb and 3 other locations - About 1 hr to fix
      lib/active_merchant/billing/gateways/firstdata_e4.rb on lines 45..63
      lib/active_merchant/billing/gateways/firstdata_e4_v27.rb on lines 37..55
      lib/active_merchant/billing/gateways/usa_epay_transaction.rb on lines 23..39

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

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

            def parse_element(reply, node)
              case node.name
              when 'CrossReferenceTransactionResult'
                reply[:transaction_result] = {}
                node.attributes.each do |a, b|
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/iridium.rb - About 1 hr to fix

        Method create_transaction_parameters has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def create_transaction_parameters(money, credit_card_or_vault_id, options)
                parameters = {
                  amount: localized_amount(money, options[:currency] || default_currency).to_s,
                  order_id: options[:order_id],
                  customer: {
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/braintree_blue.rb - About 1 hr to fix

          Method store has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def store(payment_method, options = {})
                  post = {}
                  MultiResponse.run do |r|
                    if payment_method.is_a?(NetworkTokenizationCreditCard)
                      r.process { verify(payment_method, options) }
          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 test_gateways has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

            def test_gateways
              success, failed, missing, errored, disabled = [], [], [], [], []
          
              puts "Verifying #{@gateways.count} SSL certificates\n\n"
          
          
          Severity: Minor
          Found in lib/support/ssl_verify.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_card has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def add_card(post, card, action, options = {})
                  post[:card] = {}
                  if card.is_a?(NetworkTokenizationCreditCard)
                    post[:card][:network_token] = card.number
                    post[:card][:cryptogram] = card.payment_cryptogram
          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 url has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def url(endpoint, options = {})
                  case endpoint
                  when 'settle', 'credit', 'cancel'
                    "#{test? ? test_url : live_url}transactions/#{options[:transaction_id]}/#{endpoint}"
                  when 'tokenize'
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/datatrans.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 build_authorized_request has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def build_authorized_request(action, money, authorization, credit_card, options)
                  xml = Builder::XmlMarkup.new
          
                  invoice_no, ref_no, auth_code, acq_ref_data, process_data, record_no, amount = split_authorization(authorization)
                  ref_no = '1' if ref_no.blank?
          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 parse_element has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def parse_element(node)
                  if node.has_elements?
                    response = {}
                    node.elements.each { |e|
                      key = e.name.underscore
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/authorize_net_cim.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_three_information_tags_visa has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def add_level_three_information_tags_visa(doc, payment_method, level_3_data)
                  doc.discountAmount(level_3_data[:discount_amount]) if level_3_data[:discount_amount]
                  doc.shippingAmount(level_3_data[:shipping_amount]) if level_3_data[:shipping_amount]
                  doc.dutyAmount(level_3_data[:duty_amount]) if level_3_data[:duty_amount]
                  doc.detailTax do
          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

          Method add_items has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def add_items(post, items)
                  return unless items&.kind_of?(Array)
          
                  post[:Items] = []
          
          
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/plexo.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 build_url has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def build_url(action)
                  case action
                  when 'store'
                    "#{test? ? self.test_url : self.live_url}/Recurring/#{API_VERSION}/storeToken"
                  when 'finalize3ds'
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/barclaycard_smartpay.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_three_ds has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def add_three_ds(post, payment_method, options)
                  return unless three_d_secure = options[:three_d_secure]
          
                  post[:consumerAuthenticationInformation] ||= {}
                  if payment_method.brand == 'master'
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/cyber_source_rest.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_element has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def parse_element(node)
                  if node.has_elements?
                    response = {}
                    node.elements.each do |e|
                      key = e.name.underscore
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/usa_epay_advanced.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_recurring_contract has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def add_recurring_contract(post, options = {}, payment = nil)
                  return unless options[:recurring_contract_type] || (payment.try(:network_token?) && options[:switch_cryptogram_mapping_nt])
          
                  post[:recurring] ||= {}
                  post[:recurring][:contract] = options[:recurring_contract_type] if options[:recurring_contract_type]
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/adyen.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