Showing 2 of 2 total issues
Method to_bool
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def to_bool
return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
return false if self == false || blank? || self =~ (/(false|f|no|n|0)$/i)
raise ArgumentError, "invalid value for Boolean: \"#{self}\""
- 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 permalink
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def permalink(underscore = false)
# if the slug includes one "_" at least, we consider that the "_" is used instead of "-".
_permalink = if !index('_').nil?
to_url(replace_whitespace_with: '_')
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"