fiedl/your_platform

View on GitHub
app/models/concerns/structureable.rb

Summary

Maintainability
C
1 day
Test Coverage

Method << has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

  def <<(object)
    begin
      if object.kind_of? User
        raise RuntimeError 'Users can only be assigned to groups.' unless self.kind_of? Group
        self.assign_user(object) unless self.child_users.include? object
Severity: Minor
Found in app/models/concerns/structureable.rb - About 6 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

Method << has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def <<(object)
    begin
      if object.kind_of? User
        raise RuntimeError 'Users can only be assigned to groups.' unless self.kind_of? Group
        self.assign_user(object) unless self.child_users.include? object
Severity: Minor
Found in app/models/concerns/structureable.rb - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

          elsif object.kind_of? Project
            self.child_projects << object unless self.child_projects.include? object
          elsif object.kind_of? WorkflowKit::Workflow
            # # This does not work since `child_workflows` is no real association:
            # self.child_workflows << object unless self.child_workflows.include? object
    Severity: Major
    Found in app/models/concerns/structureable.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

              unless self.events.include? object
                self.events << object
              end
      Severity: Major
      Found in app/models/concerns/structureable.rb - About 45 mins to fix

        Method children_cache_key has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def children_cache_key
            "Group#{child_group_ids.sum if respond_to?(:child_group_ids)}Page#{child_page_ids.sum if respond_to?(:child_page_ids)}User#{child_user_ids.sum if respond_to?(:child_user_ids)}"
          end
        Severity: Minor
        Found in app/models/concerns/structureable.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

        Method ancestors_cache_key has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def ancestors_cache_key
            "Group#{ancestor_group_ids if respond_to?(:ancestor_group_ids)}Page#{ancestor_page_ids if respond_to?(:ancestor_page_ids)}User#{ancestor_user_ids if respond_to?(:ancestor_user_ids)}"
          end
        Severity: Minor
        Found in app/models/concerns/structureable.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

        Method destroy_dag_links has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def destroy_dag_links
        
            # destory only child and parent links, since the indirect links
            # are destroyed automatically by the DagLink model then.
            links = self.links_as_parent + self.links_as_child
        Severity: Minor
        Found in app/models/concerns/structureable.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