app/models/children.rb
Cyclomatic complexity for << is too high. [7/6] Open
Open
def <<(new_child)
return if new_child.nil?
case new_child
when CcCondition
@cc_conditions.reader << new_child
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Ambiguous block operator. Parenthesize the method arguments if it's surely a block operator, or add a whitespace to the right of the &
if it should be a binary AND. Open
Open
to_ary.each &block
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for ambiguous operators in the first argument of a method invocation without parentheses.
Example:
# bad
# The `*` is interpreted as a splat operator but it could possibly be
# a `*` method invocation (i.e. `do_something.*(some_array)`).
do_something *some_array
Example:
# good
# With parentheses, there's no ambiguity.
do_something(*some_array)