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
Class Notification
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class Notification < OffsitePayments::Notification
class CryptError < StandardError; end
include Encryption
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']
- Read upRead up
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$/
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
- Read upRead up
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$/
- Read upRead up
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"