danmayer/coverband

View on GitHub
lib/coverband/adapters/hash_redis_store.rb

Summary

Maintainability
C
1 day
Test Coverage

File hash_redis_store.rb has 304 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "securerandom"

module Coverband
  module Adapters
    class HashRedisStore < Base
Severity: Minor
Found in lib/coverband/adapters/hash_redis_store.rb - About 3 hrs to fix

    Class HashRedisStore has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class HashRedisStore < Base
          class GetCoverageNullCacheStore
            def self.clear!(*_local_types)
            end
    
    
    Severity: Minor
    Found in lib/coverband/adapters/hash_redis_store.rb - About 3 hrs to fix

      Method coverage_for_types has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def coverage_for_types(_types, opts = {})
              page_size = opts[:page_size] || 250
              hash_data = {}
      
              runtime_file_set = files_set(Coverband::RUNTIME_TYPE)
      Severity: Minor
      Found in lib/coverband/adapters/hash_redis_store.rb - About 1 hr to fix

        Method save_report has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def save_report(report)
                report_time = Time.now.to_i
                updated_time = (type == Coverband::EAGER_TYPE) ? nil : report_time
                keys = []
                report.each_slice(@save_report_batch_size) do |slice|
        Severity: Minor
        Found in lib/coverband/adapters/hash_redis_store.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 add_coverage_for_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def add_coverage_for_file(data_from_redis, hash)
                return if data_from_redis.empty?
        
                file = data_from_redis[FILE_KEY]
                return unless file_hash(file) == data_from_redis[FILE_HASH]
        Severity: Minor
        Found in lib/coverband/adapters/hash_redis_store.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def initialize(redis, opts = {})
                super()
                @redis_namespace = opts[:redis_namespace]
                @save_report_batch_size = opts[:save_report_batch_size] || 100
                @format_version = REDIS_STORAGE_FORMAT_VERSION
        Severity: Minor
        Found in lib/coverband/adapters/hash_redis_store.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