yurijmi/better_offsite_payments

View on GitHub

Showing 50 of 50 total issues

Method shipping_address has a Cognitive Complexity of 15 (exceeds 5 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

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

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

        CURRENCY_SPECIAL_MINOR_UNITS = {
          'BIF' => 0,
          'BYR' => 0,
          'CLF' => 0,
          'CLP' => 0,
Severity: Major
Found in lib/offsite_payments/integrations/realex_offsite.rb and 1 other location - About 1 hr to fix
lib/offsite_payments/integrations/universal.rb on lines 17..46

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

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

        CURRENCY_SPECIAL_MINOR_UNITS = {
          'BIF' => 0,
          'BYR' => 0,
          'CLF' => 0,
          'CLP' => 0,
Severity: Major
Found in lib/offsite_payments/integrations/universal.rb and 1 other location - About 1 hr to fix
lib/offsite_payments/integrations/realex_offsite.rb on lines 34..63

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

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

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

                def request_redirect
                  MollieIdeal.create_payment(token, redirect_parameters)
                rescue ActiveUtils::ResponseError => e
                  case e.response.code
                  when '401', '403', '422'
        Severity: Minor
        Found in lib/offsite_payments/integrations/mollie_ideal.rb and 1 other location - About 50 mins to fix
        lib/offsite_payments/integrations/mollie_mistercash.rb on lines 63..75

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

        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 request_redirect
                      MollieMistercash.create_payment(token, redirect_parameters)
                    rescue ActiveUtils::ResponseError => e
                      case e.response.code
                      when '401', '403', '422'
        Severity: Minor
        Found in lib/offsite_payments/integrations/mollie_mistercash.rb and 1 other location - About 50 mins to fix
        lib/offsite_payments/integrations/mollie_ideal.rb on lines 116..128

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

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

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

                def amount=(money)
                  cents = money.respond_to?(:cents) ? money.cents : money
                  raise ArgumentError, "amount must be a Money object or an integer" if money.is_a?(String)
                  raise ActionViewHelperError, "amount must be greater than $0.00" if cents.to_i <= 0
        
        
        Severity: Minor
        Found in lib/offsite_payments/integrations/nochex.rb and 2 other locations - About 35 mins to fix
        lib/offsite_payments/integrations/direc_pay.rb on lines 99..104
        lib/offsite_payments/integrations/directebanking.rb on lines 91..96

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

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

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

                def amount=(money)
                  cents = money.respond_to?(:cents) ? money.cents : money
                  raise ArgumentError, "amount must be a Money object or an integer" if money.is_a?(String)
                  raise ActionViewHelperError, "amount must be greater than $0.00" if cents.to_i <= 0
        
        
        Severity: Minor
        Found in lib/offsite_payments/integrations/directebanking.rb and 2 other locations - About 35 mins to fix
        lib/offsite_payments/integrations/direc_pay.rb on lines 99..104
        lib/offsite_payments/integrations/nochex.rb on lines 96..101

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

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

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

                def amount=(money)
                  cents = money.respond_to?(:cents) ? money.cents : money
                  raise ArgumentError, "amount must be a Money object or an integer" if money.is_a?(String)
                  raise ActionViewHelperError, "amount must be greater than $0.00" if cents.to_i <= 0
        
        
        Severity: Minor
        Found in lib/offsite_payments/integrations/direc_pay.rb and 2 other locations - About 35 mins to fix
        lib/offsite_payments/integrations/directebanking.rb on lines 91..96
        lib/offsite_payments/integrations/nochex.rb on lines 96..101

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

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

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

                def customer(params = {})
                  add_field(mappings[:customer][:email], params[:email])
                  add_field(mappings[:customer][:phone], params[:phone])
                  add_field('card_holder_name', "#{params[:first_name]} #{params[:last_name]}")
        Severity: Minor
        Found in lib/offsite_payments/integrations/two_checkout.rb and 1 other location - About 35 mins to fix
        lib/offsite_payments/integrations/world_pay.rb on lines 76..79

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

        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

        Severity
        Category
        Status
        Source
        Language