rubocop-hq/rubocop

View on GitHub
lib/rubocop/cop/layout/space_around_operators.rb

Summary

Maintainability
B
4 hrs
Test Coverage
A
100%

Class SpaceAroundOperators has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

      class SpaceAroundOperators < Base
        include PrecedingFollowingAlignment
        include RangeHelp
        include RationalLiteral
        extend AutoCorrector
Severity: Minor
Found in lib/rubocop/cop/layout/space_around_operators.rb - About 3 hrs to fix

    Method excess_leading_space? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    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
    Severity: Minor
    Found in lib/rubocop/cop/layout/space_around_operators.rb - About 45 mins to fix

    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

            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."
    Severity: Minor
    Found in lib/rubocop/cop/layout/space_around_operators.rb - About 25 mins to fix

    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

    There are no issues that match your filters.

    Category
    Status