Class List
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class List
ROMAN_NUMERALS = %w(i ii iii iv v vi vii viii ix x xi xii xiii xiv x xi xii xiii xv xvi xvii xviii xix xx)
LATIN_NUMERALS = ('a'..'z').to_a
# Rubular: http://rubular.com/r/XcpaJKH0sz
Method replace_alphabet_list_parens
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def replace_alphabet_list_parens(a)
@text.gsub!(EXTRACT_ALPHABETICAL_LIST_LETTERS_REGEX).with_index do |m|
if m.include?('(')
a.eql?(Unicode::downcase(m.dup).gsub!(/\(/, '')) ? "\r&✂&#{Regexp.escape(m.gsub!(/\(/, ''))}" : "#{m}"
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
Method scan_lists
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def scan_lists(regex1, regex2, replacement, strip: false)
list_array = @text.scan(regex1).map(&:to_i)
list_array.each_with_index do |a, i|
next unless (a + 1).eql?(list_array[i + 1]) ||
(a - 1).eql?(list_array[i - 1]) ||
- 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
Consider simplifying this complex logical expression. Open
next unless (a + 1).eql?(list_array[i + 1]) ||
(a - 1).eql?(list_array[i - 1]) ||
(a.eql?(0) && list_array[i - 1].eql?(9)) ||
(a.eql?(9) && list_array[i + 1].eql?(0))
Method last_array_item_replacement
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def last_array_item_replacement(a, i, alphabet, list_array, parens)
Method other_items_replacement
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def other_items_replacement(a, i, alphabet, list_array, parens)
Method substitute_found_list_items
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def substitute_found_list_items(regex, a, strip, replacement)
@text.gsub!(regex).with_index do |m|
if a.to_s.eql?(strip ? m.strip.chop : m)
"#{Regexp.escape(a.to_s)}" + replacement
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"