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
Class Circuit
has 32 methods (exceeds 20 allowed). Consider refactoring. Open
class Circuit
CACHE_REFRESH_SUFFIX = '.faulty_refresh'
attr_reader :name
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)
- Read upRead up
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)
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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"