evolve75/RubyTree

View on GitHub

Showing 10 of 10 total issues

Class TreeNode has 46 methods (exceeds 20 allowed). Consider refactoring.
Open

  class TreeNode
    include Enumerable
    include Comparable
    include Tree::Utils::TreeMetricsHandler
    include Tree::Utils::TreePathHandler
Severity: Minor
Found in lib/tree.rb - About 6 hrs to fix

    File tree.rb has 328 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'tree/tree_deps'
    
    # This module provides a *TreeNode* class whose instances are the primary
    # objects for representing nodes in the tree.
    #
    Severity: Minor
    Found in lib/tree.rb - About 3 hrs to fix

      Method print_tree has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def print_tree(level = node_depth, max_depth = nil,
                         block = lambda { |node, prefix|
                                   puts "#{prefix} #{node.name}"
                                 })
            prefix = ''.dup # dup NEEDs to be invoked to make this mutable.
      Severity: Minor
      Found in lib/tree.rb - About 1 hr 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 siblings has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def siblings
            if block_given?
              parent.children.each { |sibling| yield sibling if sibling != self }
              self
            else
      Severity: Minor
      Found in lib/tree.rb - About 1 hr 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 postordered_each has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def postordered_each
            return to_enum(:postordered_each) unless block_given?
      
            # Using a marked node in order to skip adding the children of nodes that
            # have already been visited. This allows the stack depth to be controlled,
      Severity: Minor
      Found in lib/tree.rb - About 55 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 inordered_each has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def inordered_each
            return to_enum unless block_given?
      
            node_stack = []
            current_node = self
      Severity: Minor
      Found in lib/tree/binarytree.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 each has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def each # :yields: node
            return to_enum unless block_given?
      
            node_stack = [self] # Start with this node
      
      
      Severity: Minor
      Found in lib/tree.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 merge_trees has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def merge_trees(tree1, tree2)
              names1 = tree1.children? ? tree1.children.map(&:name) : []
              names2 = tree2.children? ? tree2.children.map(&:name) : []
      
              names_to_merge = names2 - names1
      Severity: Minor
      Found in lib/tree/utils/tree_merge_handler.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 from_hash has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def from_hash(hash)
                raise ArgumentError, 'Argument must be a type of hash'\
                                     unless hash.is_a?(Hash)
      
                raise ArgumentError, 'Hash must have one top-level element'\
      Severity: Minor
      Found in lib/tree/utils/hash_converter.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 add has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def add(child, at_index = -1)
            # Only handles the immediate child scenario
            raise ArgumentError, 'Attempting to add a nil node' unless child
      
            raise ArgumentError, 'Attempting add node to itself' if equal?(child)
      Severity: Minor
      Found in lib/tree.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

      Severity
      Category
      Status
      Source
      Language