File modifications.rb
has 252 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Spontaneous::Model::Core
# Modifications is responsible for tracking changes made to Content items
module Modifications
extend Spontaneous::Concern
Method create_ownership_modifications
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def create_ownership_modifications
change = changes_to_cascade[:visibility_path]
return false if change.nil?
old_value, new_value = change.old_value, change.new_value
return false if old_value.nil?
- 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 initialize
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(owner, user, created_at, old_visibility_path, new_owner_id, new_box_sid)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(owner, user, created_at, old_value, new_value)
Method create_visibility_modifications
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create_visibility_modifications
# We only want to record visibility changes that originate from user action, not ones propagated
# from higher up the tree, hence the check against the hidden_origin.
return false unless changed_columns.include?(:hidden) && hidden_origin.nil?
if (previous_modification = local_modifications.detect { |mod| mod.type == :visibility })
- 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 create_slug_modifications
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create_slug_modifications
change = changes_to_cascade[:slug]
return false if change.nil?
old_slug, new_slug = change.old_value, self[:slug]
return false if old_slug.nil? # ignore first change of slug from nil to provided or generated
- 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"