Showing 10 of 12 total issues
Class Timeline
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Timeline < Base
include PulseMeter::Mixins::Utils
include PulseMeter::Sensor::TimelineReduce
MAX_TIMESPAN_POINTS = 1000
Method dump!
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def dump!(safe = true)
ensure_storability!
serialized_obj = to_yaml
if safe
unless redis.hsetnx(DUMP_REDIS_KEY, name, serialized_obj)
- 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 start
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def start(max_packets = nil)
while true do
if max_packets
break if max_packets <= 0
max_packets -= 1
- 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 assert_ranged_float!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def assert_ranged_float!(options, key, from, to)
f = options[key]
raise ArgumentError, "#{key} should be defined" unless f
raise ArgumentError, "#{key} should be float" unless f.respond_to?(:to_f)
f = f.to_f
- 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 assert_positive_integer!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def assert_positive_integer!(options, key, default = nil)
value = options[key] || default
raise ArgumentError, "#{key} should be defined" unless value
raise ArgumentError, "#{key} should be integer" unless value.respond_to?(:to_i)
raise ArgumentError, "#{key} should be positive" unless value.to_i > 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 collect_ids_to_reduce
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def collect_ids_to_reduce(time, time_from, time_to)
ids = []
while (time > time_from) # go backwards
time -= interval
interval_id = get_interval_id(time)
- 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 create_sensor
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create_sensor(name, opts)
sensor_type = opts.respond_to?(:sensor_type) ? opts.sensor_type : opts[:sensor_type]
klass_s = sensor_class(sensor_type)
klass = constantize(klass_s)
raise ArgumentError, "#{klass_s} is not a valid class for a sensor" unless klass
- 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 drop_within
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def drop_within(from, till)
raise ArgumentError unless from.kind_of?(Time) && till.kind_of?(Time)
start_time, end_time = time_to_redis(from.to_i), time_to_redis(till.to_i)
current_interval_id = get_interval_id(start_time) + interval
keys = []
- 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 method_missing
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def method_missing(name, *args)
with_resque do
name = name.to_s
if sensors.has_key?(name)
sensors[name].event(*args)
- 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 define_without_observer
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def define_without_observer(method_owner, method, without_observer)
if has_method?(method_owner, method)
#for redefined methods
unless has_method?(method_owner, without_observer)
method_owner.send(:alias_method, without_observer, 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"