yurijmi/better_offsite_payments

View on GitHub

Showing 35 of 50 total issues

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 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 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 8 (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 => e
      Severity: Minor
      Found in lib/offsite_payments/integrations/sage_pay_form.rb - About 45 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

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

      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

      Severity
      Category
      Status
      Source
      Language