Method initialize
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def initialize(input)
# allow filename, string, and IO objects as input
if input.kind_of?(String)
if File.exists?(input)
input = File.new(input, 'r')
- 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 merge
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def merge(sg1_name, sg2_name, new_name=nil)
# raise error if support groups do not exist
raise RuntimeError unless sg1_probs = @transition_probabilities.delete(sg1_name) and
sg2_probs = @transition_probabilities.delete(sg2_name)
- 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 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(input)
# allow filename, string, and IO objects as input
if input.kind_of?(String)
if File.exists?(input)
input = File.new(input, 'r')
Method merge
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def merge(sg1_name, sg2_name, new_name=nil)
# raise error if support groups do not exist
raise RuntimeError unless sg1_probs = @transition_probabilities.delete(sg1_name) and
sg2_probs = @transition_probabilities.delete(sg2_name)
Method to_s
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def to_s
lines = [ "From/To,#{@sg_names.join(',')},Out" ]
[ "In", *@sg_names ].each do |input_sg|
escalations = [ @sg_names, "Out" ].flatten!.map do |output_sg|
@transition_probabilities[input_sg].map{|x| x[:sg_name] == output_sg ? x[:escalations] : nil }.compact.first || 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"