Shopify/offsite_payments

View on GitHub

Showing 40 of 57 total issues

Method verify_response has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def verify_response(params, secret)
          logstr = ''
          params.each { |key, value|
            logstr += "#{key} #{value}\n"
          }
Severity: Minor
Found in lib/offsite_payments/integrations/wirecard_checkout_page.rb - About 1 hr to fix

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

            def add_land_line_phone_for(address_type, params)
              address_field = address_type == :billing_address ? 'custPhoneNo' : 'deliveryPhNo'
    
              if params.has_key?(:phone2)
                phone = normalize_phone_number(params[:phone2])
    Severity: Minor
    Found in lib/offsite_payments/integrations/direc_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

    Method sanitize has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def sanitize(key, value)
              reject = exact = nil
    
              case key
              when /URL$/
    Severity: Minor
    Found in lib/offsite_payments/integrations/sage_pay_form.rb - About 1 hr to fix

      Method parse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse(query_string)
            return {} if query_string.blank?
      
            query_string.split('&').inject({}) do |memo, chunk|
              next memo if chunk.empty?
      Severity: Minor
      Found in lib/offsite_payments/return.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 format_phone_number has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

              def format_phone_number(phone_number, country_code)
                return nil if phone_number.nil?
      
                country_number = COUNTRY_PHONE_NUMBERS[country_code] || { :code => '0', :length => [] }
      
      
      Severity: Minor
      Found in lib/offsite_payments/integrations/realex_offsite.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 shipping_address has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def shipping_address(params = {})
                # Get the country code in the correct format
                # Use what we were given if we can't find anything
                country_code = lookup_country_code(params.delete(:country))
                add_field(mappings[:shipping_address][:country], country_code)
      Severity: Minor
      Found in lib/offsite_payments/integrations/paypal.rb - About 1 hr to fix

        Method add_line_item has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

                def add_line_item(options)
                  raise 'needs name' unless options[:name]
        
                  if @line_item_count == 30
                    # Add a note that we are not showing at least one -- AN doesn't
        Severity: Minor
        Found in lib/offsite_payments/integrations/authorize_net_sim.rb - About 55 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 create_crypt_field has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

                def create_crypt_field(fields, key)
                  parts = fields.map { |k, v| "#{k}=#{sanitize(k, v)}" unless v.nil? }.compact.shuffle
                  parts.unshift(sage_encrypt_salt(key.length, key.length * 2))
                  sage_encrypt(parts.join('&'), key)
                rescue OpenSSL::Cipher::CipherError, ArgumentError => e
        Severity: Minor
        Found in lib/offsite_payments/integrations/sage_pay_form.rb - About 55 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 sanitize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def sanitize(key, value)
                  reject = exact = nil
        
                  case key
                  when /URL$/
        Severity: Minor
        Found in lib/offsite_payments/integrations/sage_pay_form.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

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

                def add_standard_fields
                  addfields = {}
                  addfields['shopId'] = @shop_id if !@shop_id.blank?
                  addfields['paymentType'] = @paymenttype
        
        
        Severity: Minor
        Found in lib/offsite_payments/integrations/wirecard_checkout_page.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

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

                def acknowledge(authcode = nil)
                  return false if security_key.blank?
                  if ins_message?
                    Digest::MD5.hexdigest("#{ transaction_id }#{ params['vendor_id'] }#{ invoice_id }#{ secret }").upcase == security_key.upcase
                  elsif passback?
        Severity: Minor
        Found in lib/offsite_payments/integrations/two_checkout.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

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

                def lookup_state_code(country_code, state)
                  case country_code
                  when 'CA'
                    state_code = CANADIAN_STATES.find { |code, state_name| state_name.downcase == state.downcase}
                    state_code ? state_code.first : state
        Severity: Minor
        Found in lib/offsite_payments/integrations/realex_offsite.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

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

            def payment_service_for(order, account, options = {}, &proc)
              raise ArgumentError, "Missing block" unless block_given?
        
              integration_module = OffsitePayments::integration(options.delete(:service).to_s)
              service_class = integration_module.const_get('Helper')
        Severity: Minor
        Found in lib/offsite_payments/action_view_helper.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 adjust_phone_number_length(country_number[:code], processed_number)
        Severity: Major
        Found in lib/offsite_payments/integrations/realex_offsite.rb - About 30 mins to fix

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

                  def set_form_fields_for_redirect(uri)
                    return unless uri.query
          
                    CGI.parse(uri.query).each do |key, value|
                      if value.is_a?(Array) && value.length == 1
          Severity: Minor
          Found in lib/offsite_payments/integrations/mollie.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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  def parse(post)
                    # 30 + 12
                    #------------------------------8a827a0e6829
                    #Content-Disposition: form-data; name="msgtype"
                    #
          Severity: Minor
          Found in lib/offsite_payments/integrations/quickpay.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 credential_based_url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  def credential_based_url
                    raw_response = ssl_post(Pxpay.token_url, generate_request)
                    result = parse_response(raw_response)
          
                    raise ActionViewHelperError, "error - failed to get token - message was #{result[:redirect]}" unless result[:valid] == "1"
          Severity: Minor
          Found in lib/offsite_payments/integrations/pxpay.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 response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  def response(umessage = nil)
                    if @message || umessage
                      '<QPAY-CONFIRMATION-RESPONSE result="NOK" message="' + CGI.escapeHTML(umessage ? umessage : @message) + '"/>'
                    else
                      '<QPAY-CONFIRMATION-RESPONSE result="OK"/>'
          Severity: Minor
          Found in lib/offsite_payments/integrations/wirecard_checkout_page.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  def initialize(order, account, options = {})
                    super
          
                    if OffsitePayments.mode == :test || options[:test]
                      test_mode = case options[:test]
          Severity: Minor
          Found in lib/offsite_payments/integrations/world_pay.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 product has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  def product(id, options={})
                    raise ArgumentError, "Product id #{id} is not an integer between 1 and 500" unless id.to_i > 0 && id.to_i <= 500
                    requires!(options, :amount, :description)
                    options.assert_valid_keys([:description, :quantity, :amount, :discount])
          
          
          Severity: Minor
          Found in lib/offsite_payments/integrations/valitor.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

          Severity
          Category
          Status
          Source
          Language