hamstergem/hamster

View on GitHub

Showing 88 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        class Left < Realizable
          def initialize(splitter, buffer, mutex)
            super()
            @splitter, @buffer, @mutex = splitter, buffer, mutex
          end
    Severity: Major
    Found in lib/hamster/list.rb and 1 other location - About 2 hrs to fix
    lib/hamster/list.rb on lines 1447..1475

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 80.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      class Partitioned < Realizable
        def initialize(partitioner, buffer, mutex)
          super()
          @partitioner, @buffer, @mutex = partitioner, buffer, mutex
        end
    Severity: Major
    Found in lib/hamster/list.rb and 1 other location - About 2 hrs to fix
    lib/hamster/list.rb on lines 1508..1534

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 80.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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 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 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 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 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)
                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 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
              Severity
              Category
              Status
              Source
              Language