core/app/models/spree/address.rb

Summary

Maintainability
A
2 hrs
Test Coverage
A
92%

Method state_validate has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
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
Severity: Minor
Found in core/app/models/spree/address.rb - About 2 hrs 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

Class Address has 22 methods (exceeds 20 allowed). Consider refactoring.
Wontfix

  class Address < Spree::Base
    require 'validates_zipcode'

    include Spree::Metadata
    if defined?(Spree::Webhooks::HasWebhooks)
Severity: Minor
Found in core/app/models/spree/address.rb - About 2 hrs to fix

    Method postal_code_validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    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(
    Severity: Minor
    Found in core/app/models/spree/address.rb - About 25 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