core/app/models/spree/address.rb
Method state_validate
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
Open
def state_validate
# Skip state validation without country (also required)
# or when disabled by preference
return if country.blank? || !Spree::Config[:address_requires_state]
return unless country.states_required
- 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
Class Address
has 22 methods (exceeds 20 allowed). Consider refactoring. Wontfix
Wontfix
class Address < Spree::Base
require 'validates_zipcode'
include Spree::Metadata
if defined?(Spree::Webhooks::HasWebhooks)
Method postal_code_validate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def postal_code_validate
return if country.blank? || country_iso.blank? || !require_zipcode? || zipcode.blank?
return unless ::ValidatesZipcode::CldrRegexpCollection::ZIPCODES_REGEX.keys.include?(country_iso.upcase.to_sym)
formatted_zip = ::ValidatesZipcode::Formatter.new(
- 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"