Showing 5 of 7 total issues
Class ComplexDie
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class ComplexDie
# @!visibility private
# Private extension methods for GamesDice::ComplexDie probability calculations
module ProbabilityHelpers
private
Method initialize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def initialize(trigger_value, trigger_op, type, limit = 1000)
unless trigger_value.respond_to?(trigger_op)
raise ArgumentError,
"trigger_value #{trigger_value.inspect} cannot respond to trigger_op #{trigger_value.inspect}"
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 check_and_construct
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def check_and_construct(input, klass, label)
return nil unless input
raise TypeError, "#{label} should be an Array, instead got #{input.inspect}" unless input.is_a?(Array)
input.map do |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 logical_minmax
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def logical_minmax
return @basic_die.minmax unless @rerolls || @maps
return minmax_mappings(@basic_die.all_values) unless @rerolls
min_result, max_result = logical_rerolls_minmax
- 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 rerolls_loop
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def rerolls_loop(subtracting, rerolls_remaining)
loop do
rule_idx = find_matching_reroll_rule(@basic_die.result, @result.rolls.length, rerolls_remaining)
break unless rule_idx
- 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"