hamstergem/hamster

View on GitHub

Showing 81 of 88 total issues

Method realize has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def realize
      while true
        # try to "claim" the right to run the block which realizes target
        if @atomic.compare_and_swap(0,1) # full memory barrier here
          begin
Severity: Minor
Found in lib/hamster/list.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

Class Trie has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Trie
    def self.[](pairs)
      result = self.new(0)
      pairs.each { |key, val| result.put!(key, val) }
      result
Severity: Minor
Found in lib/hamster/trie.rb - About 2 hrs to fix

    Method permutation has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def permutation(n = @size)
          return enum_for(:permutation, n) if not block_given?
          if n < 0 || @size < n
            # yield nothing
          elsif n == 0
    Severity: Minor
    Found in lib/hamster/vector.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 combination has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def combination(n)
          return enum_for(:combination, n) if not block_given?
          return self if n < 0 || @size < n
          if n == 0
            yield []
    Severity: Minor
    Found in lib/hamster/vector.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 repeated_combination has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def repeated_combination(n)
          return enum_for(:repeated_combination, n) if not block_given?
          if n < 0
            # yield nothing
          elsif n == 0
    Severity: Minor
    Found in lib/hamster/vector.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 indices has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def indices(object = Undefined, i = 0, &block)
          return indices { |item| item == object } if not block_given?
          return EmptyList if empty?
          LazyList.new do
            node = self
    Severity: Minor
    Found in lib/hamster/list.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 replace_node_suffix has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def replace_node_suffix(node, bitshift, from, suffix)
          from_slot = (from >> bitshift) & INDEX_MASK
    
          if bitshift == 0
            if from_slot == 0
    Severity: Minor
    Found in lib/hamster/vector.rb - About 1 hr to fix

      Method bulk_put has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def bulk_put(key_value_pairs)
            new_entries = nil
            new_children = nil
            new_size = @size
      
      
      Severity: Minor
      Found in lib/hamster/trie.rb - About 1 hr to fix

        Method bulk_delete has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def bulk_delete(keys)
              new_entries = nil
              new_children = nil
              new_size = @size
        
        
        Severity: Minor
        Found in lib/hamster/trie.rb - About 1 hr to fix

          Method flatten_range has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def flatten_range(node, bitshift, from, to)
                from_slot = (from >> bitshift) & INDEX_MASK
                to_slot   = (to   >> bitshift) & INDEX_MASK
          
                if bitshift == 0 # are we at the bottom?
          Severity: Minor
          Found in lib/hamster/vector.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 eql? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def eql?(other)
                list = self
                loop do
                  return true if other.equal?(list)
                  return false unless other.is_a?(List)
          Severity: Minor
          Found in lib/hamster/list.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 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 disjoint? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

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

              def bsearch
                return enum_for(:bsearch) if not block_given?
                low, high, result = 0, @size, nil
                while low < high
                  mid = (low + ((high - low) >> 1))
          Severity: Minor
          Found in lib/hamster/vector.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 rindex has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def rindex(obj = (missing_arg = true))
                i = @size - 1
                if missing_arg
                  if block_given?
                    reverse_each { |item| return i if yield item; i -= 1 }
          Severity: Minor
          Found in lib/hamster/vector.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 select has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def select(&block)
                return enum_for(:select) unless block_given?
                LazyList.new do
                  list = self
                  while true
          Severity: Minor
          Found in lib/hamster/list.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 product has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def product(*vectors)
                # if no vectors passed, return "product" as in result of multiplying all items
                return super if vectors.empty?
          
                vectors.unshift(self)
          Severity: Minor
          Found in lib/hamster/vector.rb - About 1 hr to fix

            Method put has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def put(key, value)
                  index = index_for(key)
                  entry = @entries[index]
            
                  if !entry
            Severity: Minor
            Found in lib/hamster/trie.rb - About 1 hr to fix

              Method put! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def put!(key, value)
                    index = index_for(key)
                    entry = @entries[index]
                    if !entry
                      @size += 1
              Severity: Minor
              Found in lib/hamster/trie.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 at has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def at(index)
                    @entries.each do |entry|
                      if entry
                        return entry if index == 0
                        index -= 1
              Severity: Minor
              Found in lib/hamster/trie.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

              Severity
              Category
              Status
              Source
              Language