ParentSquare/faulty

View on GitHub

Showing 12 of 14 total issues

Class Redis has 35 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Redis
      # Separates the time/status for history entry strings
      ENTRY_SEPARATOR = ':'

      attr_reader :options
Severity: Minor
Found in lib/faulty/storage/redis.rb - About 4 hrs to fix

    Class Circuit has 32 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Circuit
        CACHE_REFRESH_SUFFIX = '.faulty_refresh'
    
        attr_reader :name
    
    
    Severity: Minor
    Found in lib/faulty/circuit.rb - About 4 hrs to fix

      Method finalize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def finalize
              self.cache ||= Cache::Default.new
              self.notifier ||= Events::Notifier.new
              self.storage ||= Storage::Memory.new
              self.errors = [errors] if errors && !errors.is_a?(Array)
      Severity: Minor
      Found in lib/faulty/circuit.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 check_redis_options! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def check_redis_options!
              gte5 = ::Redis::VERSION.to_f >= 5
              method = gte5 ? :config : :options
              ropts = redis do |r|
                r.instance_variable_get(:@client).public_send(method)
      Severity: Minor
      Found in lib/faulty/storage/redis.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 from_entries has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.from_entries(entries, **hash)
            window_start = Faulty.current_time - hash[:options].evaluation_window
            size = entries.size
            i = 0
            failures = 0
      Severity: Minor
      Found in lib/faulty/status.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 run_exec has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def run_exec(status, cached_value, cache_key)
            result = yield
            success!(status)
            cache_write(cache_key, result)
            result
      Severity: Minor
      Found in lib/faulty/circuit.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 entry has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def entry(circuit, time, success, status)
              key = entries_key(circuit.name)
              result = pipe do |r|
                r.call([:sadd, list_key, circuit.name])
                r.expire(list_key, options.circuit_ttl + options.list_granularity) if options.circuit_ttl
      Severity: Minor
      Found in lib/faulty/storage/redis.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 register has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def register(name, instance = nil, **config, &block)
            raise UninitializedError unless @instances
      
            if instance
              raise ArgumentError, 'Do not give config options if an instance is given' if !config.empty? || block
      Severity: Minor
      Found in lib/faulty.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 finalize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def finalize
            raise ArgumentError, "state must be a symbol in #{self.class}::STATES" unless STATES.include?(state)
            unless lock.nil? || LOCKS.include?(lock)
              raise ArgumentError, "lock must be a symbol in #{self.class}::LOCKS or nil"
            end
      Severity: Minor
      Found in lib/faulty/status.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 resolve_instance has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def resolve_instance(value)
              case value
              when String, Symbol
                result = Faulty[value]
                raise NameError, "No Faulty instance for #{value}" unless result
      Severity: Minor
      Found in lib/faulty/patch.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 init has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def init(default_name = :default, **config, &block)
            raise AlreadyInitializedError if @instances
      
            @default_instance = default_name
            @instances = Concurrent::Map.new
      Severity: Minor
      Found in lib/faulty.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 circuit_from_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def circuit_from_hash(default_name, hash, **options, &block)
              return unless hash
      
              hash = symbolize_keys(hash)
              name = hash.delete(:name) || default_name
      Severity: Minor
      Found in lib/faulty/patch.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