Showing 6 of 6 total issues
Method slice
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
Open
def slice(text, from, length, omission_width: 0, separator: nil)
scanner = StringScanner.new(text)
length_with_omission = length + omission_width
current_length = 0
start_position = 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"
Further reading
Method slice
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def slice(text, from, length, omission_width: 0, separator: nil)
scanner = StringScanner.new(text)
length_with_omission = length + omission_width
current_length = 0
start_position = 0
Avoid deeply nested control flow statements. Open
Open
if separator
word << char unless word_break
else
words << char
visible_char = true
Avoid deeply nested control flow statements. Open
Open
if word_break
word_break = false
current_length = 0
next
end
Method truncate_from
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def truncate_from(from, text, length, omission, separator)
Method truncate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def truncate(text, truncate_at = configuration.length, length: nil,
position: configuration.position,
separator: configuration.separator,
omission: configuration.omission)
truncate_at = length if length
- 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"