hamstergem/hamster

View on GitHub

Showing 88 of 88 total issues

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

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 slice has 31 lines of code (exceeds 25 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 += size if from < 0
Severity: Minor
Found in lib/hamster/list.rb - About 1 hr to fix

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

          def realize
            # another thread may get ahead of us and null out @mutex
            mutex = @mutex
            mutex && mutex.synchronize do
              return if @head != Undefined # another thread got ahead of us
    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 repeated_permutation has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def repeated_permutation(n = @size)
          return enum_for(:repeated_permutation, 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 fill has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def fill(obj, index = 0, length = nil)
          if index == 0
            length ||= size
            if length > 0
              LazyList.new do
    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 realize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def realize
          # another thread may get ahead of us and null out @mutex
          mutex = @mutex
          mutex && mutex.synchronize do
            return if @head != Undefined # another thread got ahead of us
    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 from has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def from(obj)
          case obj
          when ::Hash
            res = obj.map { |key, value| [from(key), from(value)] }
            Hamster::Hash.new(res)
    Severity: Minor
    Found in lib/hamster/nested.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 realize has 26 lines of code (exceeds 25 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 1 hr to fix

      Method find_and_delete has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def find_and_delete(key)
            index = index_for(key)
            entry = @entries[index]
            if entry && entry[0].eql?(key)
              return delete_at(index)
      Severity: Minor
      Found in lib/hamster/trie.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 replace_suffix has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def replace_suffix(from, suffix)
            # new suffix can go directly after existing elements
            raise IndexError if from > @size
            root, levels = @root, @levels
      
      
      Severity: Minor
      Found in lib/hamster/vector.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 flatten_suffix has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def flatten_suffix(node, bitshift, from, result)
            from_slot = (from >> bitshift) & INDEX_MASK
      
            if bitshift == 0
              if from_slot == 0
      Severity: Minor
      Found in lib/hamster/vector.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 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 intersection has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def intersection(other)
            if other.size < @trie.size
              if other.is_a?(Hamster::Set)
                trie = other.instance_variable_get(:@trie).select { |key, _| include?(key) }
              else
      Severity: Minor
      Found in lib/hamster/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 union has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def union(other)
            if other.is_a?(Hamster::Set)
              if other.size > size
                small_set_pairs = @trie
                large_set_trie = other.instance_variable_get(:@trie)
      Severity: Minor
      Found in lib/hamster/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 take_while has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def take_while(&block)
            return enum_for(:take_while) unless block_given?
            LazyList.new do
              next self if empty?
              next Cons.new(head, tail.take_while(&block)) if yield(head)
      Severity: Minor
      Found in lib/hamster/list.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 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 delete_at has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def delete_at(index)
            if index == 0
              tail
            elsif index < 0
              index += size if index < 0
      Severity: Minor
      Found in lib/hamster/list.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 realize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def realize
              mutex = @mutex
              mutex && mutex.synchronize do
                return if @head != Undefined
                @splitter.next_item until @splitter.done?
      Severity: Minor
      Found in lib/hamster/list.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

      Severity
      Category
      Status
      Source
      Language