core/numeric.rb
Method step
has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring. Open
Open
def step(limit=nil, step=nil, to: nil, by: nil)
unless block_given?
return to_enum(:step, limit, step, to: to, by: by) do
Rubinius::Mirror::Numeric.reflect(self).step_size(limit, step, to, by)
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
Class Numeric
has 39 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Numeric
include Comparable
# Always raises TypeError, as dup'ing Numerics is not allowed.
def initialize_copy(other)
Method step
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def step(limit=nil, step=nil, to: nil, by: nil)
unless block_given?
return to_enum(:step, limit, step, to: to, by: by) do
Rubinius::Mirror::Numeric.reflect(self).step_size(limit, step, to, by)
end
Avoid deeply nested control flow statements. Open
Open
while i < n
d = i * step + value
d = limit if limit < d
yield d
i += 1
Avoid deeply nested control flow statements. Open
Open
while i < n
d = i * step + value
d = limit if limit > d
yield d
i += 1
Method math_coerce
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def math_coerce(other, error=:coerce_error)
begin
values = other.coerce(self)
rescue
if error == :coerce_error
- 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"