Showing 10 of 10 total issues
File rspec_matchers.rb
has 259 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "d_heap/benchmarks"
module DHeap::Benchmarks
# Profiles different implementations with different sizes
Method pop
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def pop
return if @a.empty?
popped = @a.first
value = @a.pop
last_index = @a.size - 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 each_pop
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def each_pop(with_scores: false)
return to_enum(__method__, with_scores: with_scores) unless block_given?
if with_scores
yield(*pop_with_score) until empty?
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 initialize
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(name, ipe, min_time, max_time, min_iter, max_iter) # rubocop:disable Metrics/ParameterLists
Method times_faster_than
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def times_faster_than(&other)
reason, value = ___number_reason_and_value___
raise "'times_faster_than' is only for assertions" unless reason == :is_at_least
raise "Already asserting %sx comparison" % [@expect_cmp] if @expect_cmp
raise ArgumentError, "must provide a proc" unless other
- 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 take_measurements
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def take_measurements
args = [@iterations_per_round, @min_time, @max_time, @min_iter, @max_iter]
@actual_tms = measure("actual", *args, &@actual_proc)
@cmp_tms = measure("cmp", *args, &@cmp_proc) if @cmp_proc
return unless @cmp_proc
- 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 prepare_for_measurement
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def prepare_for_measurement
@volume ||= ENV.fetch("RSPEC_BENCHMARK_VOLUME", :quiet).to_sym
@max_time ||= 2
@min_time ||= 1
@min_iter ||= 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 warmup
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def warmup
return unless 0 < @warmup_time && 0 < @warmup_iter # rubocop:disable Style/NumericPredicate
args = [@warmup_iter, 0, @warmup_time, 1, @warmup_iter]
measure("warmup", *args, &@actual_proc)
measure("warmup cmp", *args, &@cmp_proc) if @cmp_proc
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
def <<(value)
raise ArgumentError unless value
index = @a.size
while 0 < index # rubocop:disable Style/NumericPredicate
parent_index = (index - 1) / 2
- 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 units_str
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def units_str(num)
if num >= 10**12; "%7.3fT" % [num.to_f / 10**12]
elsif num >= 10** 9; "%7.3fB" % [num.to_f / 10** 9]
elsif num >= 10** 6; "%7.3fM" % [num.to_f / 10** 6]
elsif num >= 10** 3; "%7.3fk" % [num.to_f / 10** 3]
- 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"