lib/rubocop/cop/layout/space_around_operators.rb
Class SpaceAroundOperators
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class SpaceAroundOperators < Base
include PrecedingFollowingAlignment
include RangeHelp
include RationalLiteral
extend AutoCorrector
Method excess_leading_space?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def excess_leading_space?(type, operator, with_space)
return false unless allow_for_alignment?
return false unless with_space.source.start_with?(EXCESSIVE_SPACE)
return !aligned_with_operator?(operator) unless type == :assignment
- 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 offense_message
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def offense_message(type, operator, with_space, right_operand)
if should_not_have_surrounding_space?(operator, right_operand)
return if with_space.is?(operator.source)
"Space around operator `#{operator.source}` detected."
- 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"