Showing 8 of 8 total issues
Method current_location
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def current_location(node)
if node.nil? then ""
elsif node.respond_to?(:id) && !node.id.nil? then "ID #{node.id}"
elsif node.respond_to?(:id) && node.id.nil? && node.respond_to?(:parent)
while !node.nil? && node.id.nil?
- 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 set_nested_value
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def set_nested_value(hash, keys, new_val)
key = keys[0]
if keys.length == 1
hash[key] = if hash[key].is_a?(::Array) then (hash[key] << new_val)
else hash[key].nil? ? new_val : [hash[key], new_val]
- 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 current_location
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def current_location(node)
if node.nil? then ""
elsif node.respond_to?(:id) && !node.id.nil? then "ID #{node.id}"
elsif node.respond_to?(:id) && node.id.nil? && node.respond_to?(:parent)
while !node.nil? && node.id.nil?
Method break_up_long_str
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def break_up_long_str(text, threshold = LONGSTR_THRESHOLD, nopunct = LONGSTR_NOPUNCT)
/^\s*$/.match?(text) and return text
text.split(/(?=(?:\s|-))/).map do |w|
if /^\s*$/.match(text) || (w.size < threshold) then w
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
Avoid deeply nested control flow statements. Open
return "Section: #{node.title}" if node.respond_to?(:context) &&
node&.context == :section
Method to_ncname
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def to_ncname(tag, asciionly: true)
asciionly and tag = HTMLEntities.new.encode(tag, :basic,
:hexadecimal)
start = tag[0]
ret1 = if %r([#{NAMECHAR}#])o.match?(start)
- 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 deep_merge
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def deep_merge(second)
merger = proc { |_, v1, v2|
if ::Hash === v1 && ::Hash === v2
v1.merge(v2, &merger)
elsif ::Array === v1 && ::Array === v2
- 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 external_path
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def external_path(path)
win = !!((RUBY_PLATFORM =~ /(win|w)(32|64)$/) ||
(RUBY_PLATFORM =~ /mswin|mingw/))
if win
path.gsub!(%{/}, "\\")
- 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"