app/models/parking_notification.rb
Class ParkingNotification
has 46 methods (exceeds 40 allowed). Consider refactoring. Open
Open
class ParkingNotification < ActiveRecord::Base
include Geocodeable
KIND_ENUM = {appears_abandoned_notification: 0, parked_incorrectly_notification: 1, impound_notification: 2}.freeze
STATUS_ENUM = {current: 0, replaced: 1, impounded: 2, retrieved: 3, impounded_retrieved: 5, resolved_otherwise: 4}.freeze
RETRIEVED_KIND_ENUM = {organization_recovery: 0, link_token_recovery: 1, user_recovery: 2}.freeze
Method set_calculated_attributes
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
Open
def set_calculated_attributes
self.initial_record_id ||= potential_initial_record&.id if is_repeat
self.repeat_number ||= calculated_repeat_number
self.resolved_at ||= calculated_resolved_at # Used by by calculated_status, so must come first
self.status = calculated_status
- 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"