hamstergem/hamster

View on GitHub
lib/hamster/trie.rb

Summary

Maintainability
D
3 days
Test Coverage

Method bulk_put has a Cognitive Complexity of 31 (exceeds 5 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 4 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 bulk_delete has a Cognitive Complexity of 23 (exceeds 5 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 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 put has a Cognitive Complexity of 20 (exceeds 5 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 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

File trie.rb has 271 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Hamster
  # @private
  class Trie
    def self.[](pairs)
      result = self.new(0)
Severity: Minor
Found in lib/hamster/trie.rb - About 2 hrs to fix

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

            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 eql? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def eql?(other)
                  return true if equal?(other)
                  return false unless instance_of?(other.class) && size == other.size
                  each do |entry|
                    return false unless other.include?(entry[0], entry[1])
            Severity: Minor
            Found in lib/hamster/trie.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 delete_at has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def delete_at(index = @entries.index { |e| e })
                  yield(@entries[index]) if block_given?
                  if size > 1
                    entries = @entries.dup
                    child = @children[index]
            Severity: Minor
            Found in lib/hamster/trie.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