rubocop-hq/rubocop

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

Summary

Maintainability
C
7 hrs
Test Coverage
A
99%

Class SpaceAroundKeyword has 43 methods (exceeds 20 allowed). Consider refactoring.
Open

      class SpaceAroundKeyword < Base
        extend AutoCorrector

        MSG_BEFORE = 'Space before keyword `%<range>s` is missing.'
        MSG_AFTER = 'Space after keyword `%<range>s` is missing.'
Severity: Minor
Found in lib/rubocop/cop/layout/space_around_keyword.rb - About 5 hrs to fix

    Method check has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def check(node, locations, begin_keyword = DO)
              locations.each do |loc|
                next unless node.loc.respond_to?(loc)
    
                range = node.loc.public_send(loc)
    Severity: Minor
    Found in lib/rubocop/cop/layout/space_around_keyword.rb - About 1 hr 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 preceded_by_operator? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def preceded_by_operator?(node, _range)
              # regular dotted method calls bind more tightly than operators
              # so we need to climb up the AST past them
              node.each_ancestor do |ancestor|
                return true if ancestor.and_type? || ancestor.or_type? || ancestor.range_type?
    Severity: Minor
    Found in lib/rubocop/cop/layout/space_around_keyword.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

    There are no issues that match your filters.

    Category
    Status