activesupport/lib/active_support/cache/redis_cache_store.rb

Summary

Maintainability
C
1 day
Test Coverage

Class RedisCacheStore has 30 methods (exceeds 20 allowed). Consider refactoring.
Open

    class RedisCacheStore < Store
      # Keys are truncated with the Active Support digest if they exceed 1kB
      MAX_KEY_BYTESIZE = 1024

      DEFAULT_REDIS_OPTIONS = {
Severity: Minor
Found in activesupport/lib/active_support/cache/redis_cache_store.rb - About 3 hrs to fix

    File redis_cache_store.rb has 289 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    begin
      gem "redis", ">= 4.0.1"
      require "redis"
      require "redis/distributed"
    rescue LoadError
    Severity: Minor
    Found in activesupport/lib/active_support/cache/redis_cache_store.rb - About 2 hrs to fix

      Method change_counter has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

              def change_counter(key, amount, options)
                redis.then do |c|
                  c = c.node_for(key) if c.is_a?(Redis::Distributed)
      
                  expires_in = options[:expires_in]
      Severity: Minor
      Found in activesupport/lib/active_support/cache/redis_cache_store.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 read_multi_entries has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

              def read_multi_entries(names, **options)
                options = merged_options(options)
                return {} if names == []
                raw = options&.fetch(:raw, false)
      
      
      Severity: Minor
      Found in activesupport/lib/active_support/cache/redis_cache_store.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 delete_matched has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def delete_matched(matcher, options = nil)
              unless String === matcher
                raise ArgumentError, "Only Redis glob strings are supported: #{matcher.inspect}"
              end
              pattern = namespace_key(matcher, options)
      Severity: Minor
      Found in activesupport/lib/active_support/cache/redis_cache_store.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 write_serialized_entry has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def write_serialized_entry(key, payload, raw: false, unless_exist: false, expires_in: nil, race_condition_ttl: nil, pipeline: nil, **options)
                # If race condition TTL is in use, ensure that cache entries
                # stick around a bit longer after they would have expired
                # so we can purposefully serve stale entries.
                if race_condition_ttl && expires_in && expires_in > 0 && !raw
      Severity: Minor
      Found in activesupport/lib/active_support/cache/redis_cache_store.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

      There are no issues that match your filters.

      Category
      Status