Shopify/active_merchant

View on GitHub
lib/active_merchant/billing/gateways/payu_latam.rb

Summary

Maintainability
D
2 days
Test Coverage

Class PayuLatamGateway has 44 methods (exceeds 20 allowed). Consider refactoring.
Open

    class PayuLatamGateway < Gateway
      self.display_name = 'PayU Latam'
      self.homepage_url = 'http://www.payulatam.com'

      self.test_url = 'https://sandbox.api.payulatam.com/payments-api/4.0/service.cgi'
Severity: Minor
Found in lib/active_merchant/billing/gateways/payu_latam.rb - About 6 hrs to fix

    File payu_latam.rb has 410 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'digest/md5'
    
    module ActiveMerchant #:nodoc:
      module Billing #:nodoc:
        class PayuLatamGateway < Gateway
    Severity: Minor
    Found in lib/active_merchant/billing/gateways/payu_latam.rb - About 5 hrs to fix

      Method add_buyer has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_buyer(post, payment_method, options)
              buyer = {}
              if buyer_hash = options[:buyer]
                buyer[:fullName] = buyer_hash[:name]
                buyer[:dniNumber] = buyer_hash[:dni_number]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/payu_latam.rb - About 2 hrs 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_payment_method has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_payment_method(post, payment_method, options)
              if payment_method.is_a?(String)
                brand, token = split_authorization(payment_method)
                credit_card = {}
                credit_card[:securityCode] = options[:cvv] if options[:cvv]
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/payu_latam.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 auth_or_sale has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def auth_or_sale(post, transaction_type, amount, payment_method, options)
      Severity: Minor
      Found in lib/active_merchant/billing/gateways/payu_latam.rb - About 35 mins to fix

        Method commit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def commit(action, params)
                raw_response = ssl_post(url, post_data(params), headers)
                response = parse(raw_response)
              rescue ResponseError => e
                raw_response = e.response.body
        Severity: Minor
        Found in lib/active_merchant/billing/gateways/payu_latam.rb - About 35 mins 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

        Avoid too many return statements within this method.
        Open

                return response_code if response_code
        Severity: Major
        Found in lib/active_merchant/billing/gateways/payu_latam.rb - About 30 mins to fix

          Method add_payer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def add_payer(post, payment_method, options)
                  address = options[:billing_address]
                  payer = {}
                  payer[:fullName] = payment_method.name.strip
                  payer[:contactPhone] = address[:phone] if address && address[:phone]
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/payu_latam.rb - About 25 mins 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 message_from_transaction_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def message_from_transaction_response(success, response)
                  response_code = response.dig('transactionResponse', 'responseCode') || response.dig('transactionResponse', 'pendingReason')
                  return response_code if success
                  return response_code + ' | ' + response.dig('transactionResponse', 'paymentNetworkResponseErrorMessage') if response.dig('transactionResponse', 'paymentNetworkResponseErrorMessage')
                  return response.dig('transactionResponse', 'responseMessage') if response.dig('transactionResponse', 'responseMessage')
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/payu_latam.rb - About 25 mins 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 error_from has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def error_from(action, response)
                  case action
                  when 'store'
                    response['creditCardToken']['errorDescription'] if response['creditCardToken']
                  when 'verify_credentials'
          Severity: Minor
          Found in lib/active_merchant/billing/gateways/payu_latam.rb - About 25 mins 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

          There are no issues that match your filters.

          Category
          Status