Seberius/cache_lib

View on GitHub

Showing 7 of 7 total issues

Class Cache has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Cache
      attr_reader :limit, :ttl

      def initialize
        @limit = nil
Severity: Minor
Found in lib/cache_lib/basic/cache.rb - About 2 hrs to fix

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

          def limit=(args)
            limit, ttl = args
    
            limit ||= @limit
            ttl ||= @ttl
    Severity: Minor
    Found in lib/cache_lib/ttl/cache.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 hit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def hit(key)
            value = @cache[key]
    
            if @stack.key?(key)
              if @queue.key?(key)
    Severity: Minor
    Found in lib/cache_lib/lirs/cache.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def initialize(*args)
            limit, ttl = args
    
            fail ArgumentError, "Cache Limit must be 1 or greater: #{limit}" unless
                limit && (limit.is_a? Numeric) && limit > 0
    Severity: Minor
    Found in lib/cache_lib/ttl/cache.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 miss has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def miss(key, value)
            if @cache.size < @s_limit
              @cache[key] = value
              @stack.set_head(key, nil)
            else
    Severity: Minor
    Found in lib/cache_lib/lirs/cache.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def initialize(*args)
            s_limit, q_limit = args
    
            fail ArgumentError, "S Limit must be 1 or greater: #{s_limit}" unless
                s_limit && (s_limit.is_a? Numeric) && s_limit > 0
    Severity: Minor
    Found in lib/cache_lib/lirs/cache.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 evict has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def evict(key)
            return unless @cache.key?(key)
    
            value = @cache.delete(key)
    
    
    Severity: Minor
    Found in lib/cache_lib/lirs/cache.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

    Severity
    Category
    Status
    Source
    Language