app/services/spam_estimator.rb
Method vowel_frequency_suspiciousness
has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring. Open
Open
def vowel_frequency_suspiciousness(str, str_length = nil, str_downlate = nil)
str_length ||= str.length.to_f
return 0 if str_length < 4 # 3 letters or less get a pass
vowel_percent = vowel_ratio(str, str_length) * 100
- 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
Open
if str_length < 15
vowel_percent
elsif str_length < 30
vowel_percent + 15
else
Avoid deeply nested control flow statements. Open
Open
elsif vowel_percent > 40
vowel_percent - 40
else
0