Showing 39 of 39 total issues
File tdigest.rb
has 280 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'rbtree'
module Airbrake
# Ruby implementation of Ted Dunning's t-digest data structure.
#
Method percentile
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def percentile(p)
is_array = p.is_a? Array
p = [p] unless is_array
p.map! do |item|
unless (0..1).cover?(item)
- 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 TDigest
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class TDigest
VERBOSE_ENCODING = 1
SMALL_ENCODING = 2
# Centroid represents a number of data points.
Method from_bytes
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def self.from_bytes(bytes)
format, compression, size = bytes.unpack('NGN')
tdigest = new(1 / compression)
start_idx = 16 # after header
- 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 p_rank
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def p_rank(x)
is_array = x.is_a? Array
x = [x] unless is_array
min = @centroids.first
- 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_bytes
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.from_bytes(bytes)
format, compression, size = bytes.unpack('NGN')
tdigest = new(1 / compression)
start_idx = 16 # after header
Method parse
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.parse(response)
code = response.code.to_i
body = response.body
begin
Method find_from_packed_refs
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def find_from_packed_refs(head)
packed_refs_path = File.join(@git_path, 'packed-refs')
return head unless File.exist?(packed_refs_path)
File.readlines(packed_refs_path).each do |line|
- 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 _digest
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _digest(x, n)
# Use 'first' and 'last' instead of min/max because of performance reasons
# This works because RBTree is sorted
min = min.last if (min = @centroids.first)
max = max.last if (max = @centroids.last)
- 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 parse_backtrace
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def parse_backtrace(exception)
regexp = best_regexp_for(exception)
root_directory = Airbrake::Config.instance.root_directory.to_s
exception.backtrace.map.with_index do |stackframe, i|
- 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 initialize
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(user_config = {})
self.proxy = {}
self.queue_size = 100
self.workers = 1
self.code_hunks = true
Method attach_repository
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def attach_repository(notice)
if @repository
notice[:context][:repository] = @repository
return
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 _cumulate
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _cumulate(exact: false, force: false)
unless force
factor = if @last_cumulate == 0
Float::INFINITY
else
- 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 to_json
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def to_json(*_args)
loop do
begin
json = @payload.to_json
rescue *JSON_EXCEPTIONS => ex
- 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 filter_hash
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def filter_hash(hash) # rubocop:disable Metrics/AbcSize
return hash unless hash.is_a?(Hash)
hash_copy = hash.dup
- 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 get_lines
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_lines(file, start_line, end_line)
return unless (cached_file = get_from_cache(file))
lines = {}
cached_file.with_index(1) do |l, i|
- 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 call
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def call(notice) # rubocop:disable Metrics/AbcSize
exception = notice.stash[:exception]
return unless exception.respond_to?(:to_airbrake)
attributes = 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 call
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def call(notice)
return unless defined?(Gem)
notice[:errors].each do |error|
Gem.path.each do |gem_path|
- 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 bound_mean_cumn
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def bound_mean_cumn(cumn)
last_c = nil
bounds = []
@centroids.each_value do |v|
if v.mean_cumn == cumn
- 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 find_nearest
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def find_nearest(x)
return if size == 0
upper_key, upper = @centroids.upper_bound(x)
lower_key, lower = @centroids.lower_bound(x)
- 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"