Showing 14 of 16 total issues
Method build_record_header_metrics_method
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def build_record_header_metrics_method
if tracker.suite_enabled?(:rack)
define_singleton_method(:record_header_metrics) do |env|
queue_start = env['HTTP_X_REQUEST_START'] || env['HTTP_X_QUEUE_START']
if queue_start
- 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
Class Tracker
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class Tracker
extend Forwardable
def_delegators :collector, :increment, :measure, :timing, :group
def_delegators :logger, :log
Method increment
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def increment(counter, options={})
metric = counter.to_s
if options.is_a?(INTEGER_CLASS)
# suppport legacy style
options = {by: options}
- 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 measure
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def measure(*args, &block)
options = {}
event = args[0].to_s
returned = nil
Method fetch
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def fetch(key, options={})
return nil if @cache.empty?
return fetch_percentile(key, options) if options[:percentile]
measurements = nil
tags = options[:tags] || @default_tags
- 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 compensated_repeat
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def compensated_repeat(period, first_run = nil)
next_run = first_run || start_time(period)
until @interrupt do
now = Time.now
if now >= next_run
- 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 measure
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def measure(*args, &block)
options = {}
event = args[0].to_s
returned = nil
- 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 increment
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def increment(counter, options={})
metric = counter.to_s
if options.is_a?(INTEGER_CLASS)
# suppport legacy style
options = {by: options}
Method flush_to
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def flush_to(queue, opts={})
queued = nil
@lock.synchronize do
return if @cache.empty?
queued = @cache.queued
- 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_time
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def start_time(period)
if @sync
earliest = Time.now + period
# already on a whole minute
return earliest if earliest.sec == 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 build_record_request_metrics_method
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def build_record_request_metrics_method
body = "def record_request_metrics(status, http_method, duration)\n"
body << "return if config.disable_rack_metrics\n"
unless config.instance_of?(Librato::Rack::Configuration::SuitesNone)
- 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 should_start?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def should_start?
if !config.user || !config.token
# don't show this unless we're debugging, expected behavior
log :debug, 'halting: credentials not present.'
elsif config.autorun == false
- 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 build_tags
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def build_tags
tags = {}
tags.tap do
if ENV["LIBRATO_TAGS"]
ENV["LIBRATO_TAGS"].split(",")
- 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 validate_measurements
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_measurements
@queued[:measurements].delete_if do |entry|
name = entry[:name].to_s
tags = entry[:tags]
if name !~ METRIC_NAME_REGEX
- 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"