lib/extended_email_reply_parser/email_reply_parser/email.rb
Method split_fragments_at
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Open
def split_fragments_at(regex)
@fragments = @fragments.collect do |fragment|
if fragment.to_s
first_text, *rest = fragment.to_s.split(regex)
- 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
Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the /
if it should be a division. Open
Open
fragment.content = fragment.content.gsub /\n *?\n>/m, "\n>"
- Read upRead up
- Exclude checks
This cop checks for ambiguous regexp literals in the first argument of a method invocation without parentheses.
Example:
# bad
# This is interpreted as a method invocation with a regexp literal,
# but it could possibly be `/` method invocations.
# (i.e. `do_something./(pattern)./(i)`)
do_something /pattern/i
Example:
# good
# With parentheses, there's no ambiguity.
do_something(/pattern/i)