Showing 10 of 24 total issues
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 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
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
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 other_items_replacement
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def other_items_replacement(a, i, alphabet, list_array, parens)
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 search_for_abbreviations_in_string
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def search_for_abbreviations_in_string(txt)
original = txt.dup
downcased = Unicode::downcase(txt)
@language::Abbreviation::ABBREVIATIONS.each do |abbreviation|
stripped = abbreviation.strip
- 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 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"
Further reading
Method post_process_segments
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def post_process_segments(txt)
return txt if txt.length < 2 && txt =~ /\A[a-zA-Z]*\Z/
return if consecutive_underscore?(txt) || txt.length < 2
Rule.apply(
txt,
- 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_for_replacements
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def scan_for_replacements(txt, am, index, character_array)
character = character_array[index]
prepositive = @language::Abbreviation::PREPOSITIVE_ABBREVIATIONS
number_abbr = @language::Abbreviation::NUMBER_ABBREVIATIONS
upper = /[[:upper:]]/.match(character.to_s)
- 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"