hamstergem/hamster

View on GitHub
lib/hamster/vector.rb

Summary

Maintainability
F
6 days
Test Coverage

File vector.rb has 665 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "hamster/immutable"
require "hamster/enumerable"
require "hamster/hash"
require "hamster/associable"

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

    Class Vector has 67 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Vector
        include Immutable
        include Enumerable
        include Associable
    
    
    Severity: Major
    Found in lib/hamster/vector.rb - About 1 day to fix

      Method replace_node_suffix has a Cognitive Complexity of 25 (exceeds 5 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 3 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 product has a Cognitive Complexity of 22 (exceeds 5 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 3 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 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 += @size if from < 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 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 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 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 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 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 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 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 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

          Avoid too many return statements within this method.
          Open

                    return result if bump_counters[]
          Severity: Major
          Found in lib/hamster/vector.rb - About 30 mins to fix

            Method initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def initialize(items=[].freeze)
                  items = items.to_a
                  if items.size <= 32
                    items = items.dup.freeze if !items.frozen?
                    @root, @size, @levels = items, items.size, 0
            Severity: Minor
            Found in lib/hamster/vector.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 fill has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def fill(object, index = 0, length = nil)
                  raise IndexError if index < -@size
                  index += @size if index < 0
                  length ||= @size - index # to the end of the array, if no length given
            
            
            Severity: Minor
            Found in lib/hamster/vector.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 update_root has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def update_root(index, item)
                  root, levels = @root, @levels
                  while index >= (1 << (BITS_PER_LEVEL * (levels + 1)))
                    root = [root].freeze
                    levels += 1
            Severity: Minor
            Found in lib/hamster/vector.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