SpontaneousCMS/spontaneous

View on GitHub
lib/spontaneous/model/core/modifications.rb

Summary

Maintainability
B
5 hrs
Test Coverage

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

Severity: Minor
Found in lib/spontaneous/model/core/modifications.rb - About 2 hrs to fix

    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?
    Severity: Minor
    Found in lib/spontaneous/model/core/modifications.rb - About 45 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

    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)
    Severity: Minor
    Found in lib/spontaneous/model/core/modifications.rb - About 45 mins to fix

      Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def initialize(owner, user, created_at, old_value, new_value)
      Severity: Minor
      Found in lib/spontaneous/model/core/modifications.rb - About 35 mins to fix

        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 })
        Severity: Minor
        Found in lib/spontaneous/model/core/modifications.rb - About 35 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

        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
        Severity: Minor
        Found in lib/spontaneous/model/core/modifications.rb - About 35 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