lib/rubocop/cop/style/sample.rb
Method range_size
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def range_size(range_node)
vals = range_node.to_a
return :unknown unless vals.all? { |val| val.nil? || val.int_type? }
low, high = vals.map { |val| val.nil? ? 0 : val.children[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 sample_size_for_one_arg
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def sample_size_for_one_arg(arg)
if arg.range_type?
range_size(arg)
elsif arg.int_type?
[0, -1].include?(arg.to_a.first) ? nil : :unknown
- 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"