hamstergem/hamster

View on GitHub
lib/hamster/sorted_set.rb

Summary

Maintainability
F
4 days
Test Coverage

File sorted_set.rb has 742 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "hamster/immutable"
require "hamster/enumerable"

module Hamster

Severity: Major
Found in lib/hamster/sorted_set.rb - About 1 day to fix

    Class SortedSet has 53 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class SortedSet
        include Immutable
        include Enumerable
    
        class << self
    Severity: Major
    Found in lib/hamster/sorted_set.rb - About 7 hrs to fix

      Class AVLNode has 34 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class AVLNode
            def self.from_items(items, comparator, from = 0, to = items.size-1) # items must be sorted
              size = to - from + 1
              if size >= 3
                middle = (to + from) / 2
      Severity: Minor
      Found in lib/hamster/sorted_set.rb - About 4 hrs to fix

        Class Empty has 27 methods (exceeds 20 allowed). Consider refactoring.
        Open

              class Empty
                def initialize(comparator); @comparator = comparator; end
                def natural_order?; false; end
                def left;  self;    end
                def right; self;    end
        Severity: Minor
        Found in lib/hamster/sorted_set.rb - About 3 hrs to fix

          Method slice has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              def slice(arg, length = (missing_length = true))
                if missing_length
                  if arg.is_a?(Range)
                    from, to = arg.begin, arg.end
                    from += @node.size if from < 0
          Severity: Minor
          Found in lib/hamster/sorted_set.rb - About 2 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 eql? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def eql?(other)
                return true if other.equal?(self)
                return false if not instance_of?(other.class)
                return false if size != other.size
                a, b = self.to_enum, other.to_enum
          Severity: Minor
          Found in lib/hamster/sorted_set.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 delete has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def delete(item)
                  dir = direction(item)
                  if dir == 0
                    if @right.empty?
                      return @left # replace this node with its only child
          Severity: Minor
          Found in lib/hamster/sorted_set.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 find_index has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def find_index(obj = (missing_obj = true), &block)
                if !missing_obj
                  # Enumerable provides a default implementation, but this is more efficient
                  node = @node
                  index = node.left.size
          Severity: Minor
          Found in lib/hamster/sorted_set.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 disjoint? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def disjoint?(other)
                if size < other.size
                  each { |item| return false if other.include?(item) }
                else
                  other.each { |item| return false if include?(item) }
          Severity: Minor
          Found in lib/hamster/sorted_set.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 subsequence has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def subsequence(from, length)
                return nil if from > @node.size || from < 0 || length < 0
                length = @node.size - from if @node.size < from + length
                if length == 0
                  if @node.natural_order?
          Severity: Minor
          Found in lib/hamster/sorted_set.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 bulk_delete has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def bulk_delete(items)
                  return self if items.empty?
                  if items.size == 1
                    catch :not_present do
                      return delete(items.first)
          Severity: Minor
          Found in lib/hamster/sorted_set.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def initialize(items=[], &block)
                items = items.to_a
                if block
                  if block.arity == 1 || block.arity == -1
                    comparator = lambda { |a,b| block.call(a) <=> block.call(b) }
          Severity: Minor
          Found in lib/hamster/sorted_set.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