File array.rb
has 1666 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Array
include Enumerable
def self.allocate
Rubinius.primitive :array_allocate
Class Array
has 105 methods (exceeds 20 allowed). Consider refactoring. Open
class Array
include Enumerable
def self.allocate
Rubinius.primitive :array_allocate
Method set_index
has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring. Open
def set_index(index, ent, fin=undefined)
Rubinius.primitive :array_aset
Rubinius.check_frozen
- 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 sample
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
def sample(count=undefined, options=undefined)
return at Kernel.rand(size) if undefined.equal? count
if undefined.equal? options
if o = Rubinius::Type.check_convert_type(count, Hash, :to_hash)
- 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 slice!
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
def slice!(start, length=undefined)
Rubinius.check_frozen
if undefined.equal? length
if start.kind_of? Range
- 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 fill
has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring. Open
def fill(a=undefined, b=undefined, c=undefined)
Rubinius.check_frozen
if block_given?
unless undefined.equal?(c)
- 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 []
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
def [](arg1, arg2=nil)
case arg1
# This is split out from the generic case and put first because
# it is by far the most common case and we want to deal with it
- 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 set_index
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_index(index, ent, fin=undefined)
Rubinius.primitive :array_aset
Rubinius.check_frozen
Method join
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def join(sep=nil)
return "".force_encoding(Encoding::US_ASCII) if @total == 0
out = ""
raise ArgumentError, "recursive array join" if Thread.detect_recursion self do
- 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 sample
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
def sample(count=undefined, options=undefined)
return at Kernel.rand(size) if undefined.equal? count
if undefined.equal? options
if o = Rubinius::Type.check_convert_type(count, Hash, :to_hash)
Method values_at
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def values_at(*args)
out = []
args.each do |elem|
# Cannot use #[] because of subtly different errors
- 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 fill
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fill(a=undefined, b=undefined, c=undefined)
Rubinius.check_frozen
if block_given?
unless undefined.equal?(c)
Method rindex
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def rindex(obj=undefined)
if undefined.equal?(obj)
return to_enum(:rindex, obj) unless block_given?
i = @total - 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 recursively_flatten
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def recursively_flatten(array, out, max_levels = -1)
modified = false
# Strict equality since < 0 means 'infinite'
if max_levels == 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 mergesort!
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def mergesort!
width = 7
@scratch = Rubinius::Tuple.new @tuple.size
# do a pre-loop to create a bunch of short sorted runs; isort on these
- 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 mergesort_block!
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def mergesort_block!(block)
width = 7
@scratch = Rubinius::Tuple.new @tuple.size
left = @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
Method initialize
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def initialize(size_or_array=undefined, obj=undefined)
Rubinius.check_frozen
if undefined.equal?(size_or_array)
unless @total == 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 slice!
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
def slice!(start, length=undefined)
Rubinius.check_frozen
if undefined.equal? length
if start.kind_of? Range
Method []
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def [](arg1, arg2=nil)
case arg1
# This is split out from the generic case and put first because
# it is by far the most common case and we want to deal with it
Method ==
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def ==(other)
return true if equal?(other)
unless other.kind_of?(Array)
return false unless other.respond_to?(:to_ary)
- 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 bsearch_index
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def bsearch_index
return to_enum :bsearch_index unless block_given?
m = Rubinius::Mirror::Array.reflect self
- 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 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(size_or_array=undefined, obj=undefined)
Rubinius.check_frozen
if undefined.equal?(size_or_array)
unless @total == 0
Method combination
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def combination(num)
num = Rubinius::Type.coerce_to_collection_index num
unless block_given?
return to_enum(:combination, num) do
Method isort!
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def isort!(left, right)
i = left + 1
tup = @tuple
- 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 combination
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def combination(num)
num = Rubinius::Type.coerce_to_collection_index num
unless block_given?
return to_enum(:combination, num) do
- 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 permutation
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def permutation(num=undefined, &block)
unless block_given?
return to_enum(:permutation, num) do
Rubinius::Mirror::Array.reflect(self).permutation_size(num)
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 recursively_flatten
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def recursively_flatten(array, out, max_levels = -1)
modified = false
# Strict equality since < 0 means 'infinite'
if max_levels == 0
Method *
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def *(multiplier)
if multiplier.respond_to? :to_str
return join(multiplier)
else
Method <=>
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def <=>(other)
other = Rubinius::Type.check_convert_type other, Array, :to_ary
return 0 if equal? other
return nil if other.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 zip
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def zip(*others)
out = Array.new(size) { [] }
others = others.map do |other|
if other.respond_to?(:to_ary)
other.to_ary
- 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 pop
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def pop(many=undefined)
Rubinius.check_frozen
if undefined.equal?(many)
return nil if @total == 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 join
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def join(sep=nil)
return "".force_encoding(Encoding::US_ASCII) if @total == 0
out = ""
raise ArgumentError, "recursive array join" if Thread.detect_recursion self do
Method bsearch_index
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def bsearch_index
return to_enum :bsearch_index unless block_given?
m = Rubinius::Mirror::Array.reflect self
Method zip
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def zip(*others)
out = Array.new(size) { [] }
others = others.map do |other|
if other.respond_to?(:to_ary)
other.to_ary
Method mergesort_block!
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def mergesort_block!(block)
width = 7
@scratch = Rubinius::Tuple.new @tuple.size
left = @start
Method mergesort!
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def mergesort!
width = 7
@scratch = Rubinius::Tuple.new @tuple.size
# do a pre-loop to create a bunch of short sorted runs; isort on these
Method hash
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def hash
hash_val = size
mask = Fixnum::MAX >> 1
# This is duplicated and manually inlined code from Thread for performance
Method permutation
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def permutation(num=undefined, &block)
unless block_given?
return to_enum(:permutation, num) do
Rubinius::Mirror::Array.reflect(self).permutation_size(num)
end
Method count
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def count(item = undefined)
seq = 0
if !undefined.equal?(item)
each { |o| seq += 1 if item == o }
elsif block_given?
- 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 isort_block!
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def isort_block!(left, right, block)
i = left + 1
while i < right
j = 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 delete_range
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def delete_range(index, del_length)
# optimize for fast removal..
reg_start = index + del_length
reg_length = @total - reg_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
Method __permute__
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def __permute__(num, perm, index, used, &block)
# Recursively compute permutations of r elements of the set [0..n-1].
# When we have a complete permutation of array indexes, copy the values
# at those indexes into a new array and yield that 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 eql?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def eql?(other)
return true if equal? other
return false unless other.kind_of?(Array)
return false if @total != other.size
- 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 fetch
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def fetch(idx, default=undefined)
orig = idx
idx = Rubinius::Type.coerce_to_collection_index idx
idx += @total if idx < 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 sort_inplace
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def sort_inplace(&block)
Rubinius.check_frozen
return self unless @total > 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
Avoid deeply nested control flow statements. Open
if k == result[j]
abandon = true
break
end
Method *
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def *(multiplier)
if multiplier.respond_to? :to_str
return join(multiplier)
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 __permute__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __permute__(num, perm, index, used, &block)
Method compile_repeated_combinations
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def compile_repeated_combinations(combination_size, place, index, depth, &block)
Method shuffle!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def shuffle!(options = undefined)
Rubinius.check_frozen
random_generator = Kernel
- 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 cycle
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def cycle(n=nil)
unless block_given?
return to_enum(:cycle, n) do
Rubinius::EnumerableHelper.cycle_size(size, n)
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 delete_if
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def delete_if
return to_enum(:delete_if) { size } unless block_given?
Rubinius.check_frozen
- 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
Avoid too many return
statements within this method. Open
return new_range(0, 0) if right_idx < start_idx
Avoid too many return
statements within this method. Open
return nil
Avoid too many return
statements within this method. Open
return nil if count < 0
Avoid too many return
statements within this method. Open
return nil if start_idx >= @total
Avoid too many return
statements within this method. Open
return new_range(@start + start_idx, count)
Avoid too many return
statements within this method. Open
return @tuple.at(@start + start_idx)
Avoid too many return
statements within this method. Open
return new_range(0, 0) if start_idx == @total
Avoid too many return
statements within this method. Open
return nil if start_idx < 0
Avoid too many return
statements within this method. Open
return nil
Avoid too many return
statements within this method. Open
return false unless self_tuple[self_idx] == other_tuple[other_idx]
Avoid too many return
statements within this method. Open
return count == size ? result : result[0, count]
Avoid too many return
statements within this method. Open
return result
Avoid too many return
statements within this method. Open
return [at(i), at(j)]
Method bottom_up_merge_block
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def bottom_up_merge_block(left, right, last, block)
left_index = left
right_index = right
i = left
- 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 shift
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def shift(n=undefined)
Rubinius.check_frozen
if undefined.equal?(n)
return nil if @total == 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 delete
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def delete(obj)
key = undefined
i = @start
total = i + @total
tuple = @tuple
- 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 hash
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def hash
hash_val = size
mask = Fixnum::MAX >> 1
# This is duplicated and manually inlined code from Thread for performance
- 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 inspect
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def inspect
return "[]".force_encoding(Encoding::US_ASCII) if @total == 0
comma = ", "
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 bottom_up_merge
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def bottom_up_merge(left, right, last)
left_index = left
right_index = right
i = left
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def dig(index, *remaining_indeces)
item = self[index]
return item if remaining_indeces.empty? || item.nil?
raise TypeError, "#{item.class} does not have #dig method" unless item.respond_to?(:dig)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 29.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if arg2
count = Rubinius::Type.coerce_to_collection_index arg2
else
return nil if start_idx >= @total
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 27.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if arg2
count = Rubinius::Type.coerce_to_collection_index arg2
else
return nil if start_idx >= @total
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 27.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def &(other)
other = Rubinius::Type.coerce_to other, Array, :to_ary
array = []
im = Rubinius::IdentityMap.from other
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 27.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def -(other)
other = Rubinius::Type.coerce_to other, Array, :to_ary
array = []
im = Rubinius::IdentityMap.from other
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 27.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76