yurijmi/better_offsite_payments

View on GitHub
lib/offsite_payments/integrations/sage_pay_form.rb

Summary

Maintainability
C
1 day
Test Coverage

File sage_pay_form.rb has 292 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module OffsitePayments #:nodoc:
  module Integrations #:nodoc:
    module SagePayForm
      mattr_accessor :production_url
      mattr_accessor :test_url
Severity: Minor
Found in lib/offsite_payments/integrations/sage_pay_form.rb - About 3 hrs to fix

    Class Notification has 25 methods (exceeds 20 allowed). Consider refactoring.
    Open

          class Notification < OffsitePayments::Notification
            class CryptError < StandardError; end
    
            include Encryption
    
    
    Severity: Minor
    Found in lib/offsite_payments/integrations/sage_pay_form.rb - About 2 hrs to fix

      Method form_fields has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

              def form_fields
                map_billing_address_to_shipping_address unless @shipping_address_set
      
                fields['DeliveryFirstnames'] ||= fields['BillingFirstnames']
                fields['DeliverySurname']    ||= fields['BillingSurname']
      Severity: Minor
      Found in lib/offsite_payments/integrations/sage_pay_form.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 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 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

        There are no issues that match your filters.

        Category
        Status