Class Payment
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class Payment < Spree::Base
include Spree::Core::NumberGenerator.new(prefix: 'P', letters: true, length: 7)
include Spree::NumberIdentifier
include Spree::NumberAsParam
include Spree::Metadata
Method create_payment_profile
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def create_payment_profile
# Don't attempt to create on bad payments.
return if has_invalid_state?
# Payment profile cannot be created without source
return unless source
- 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 validate_source
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate_source
if source && !source.valid?
source.errors.map { |error| { field: error.attribute, message: error&.message } }.each do |err|
next if err[:field].blank? || err[:message].blank?
- 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 build_source
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def build_source
return unless new_record?
if source_attributes.present? && source.blank? && payment_method.try(:payment_source_class)
self.source = payment_method.payment_source_class.new(source_attributes)
- 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"