rubocop-hq/rubocop

View on GitHub
lib/rubocop/cop/lint/redundant_cop_disable_directive.rb

Summary

Maintainability
C
1 day
Test Coverage
A
100%

Class RedundantCopDisableDirective has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

      class RedundantCopDisableDirective < Base # rubocop:todo Metrics/ClassLength
        include RangeHelp
        extend AutoCorrector

        COP_NAME = 'Lint/RedundantCopDisableDirective'
Severity: Minor
Found in lib/rubocop/cop/lint/redundant_cop_disable_directive.rb - About 4 hrs to fix

    Method each_already_disabled has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

            def each_already_disabled(cop, line_ranges)
              line_ranges.each_cons(2) do |previous_range, range|
                next if ignore_offense?(range)
                # If a cop is disabled in a range that begins on the same line as
                # the end of the previous range, it means that the cop was
    Severity: Minor
    Found in lib/rubocop/cop/lint/redundant_cop_disable_directive.rb - About 2 hrs 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 each_line_range has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

            def each_line_range(cop, line_ranges)
              line_ranges.each_with_index do |line_range, line_range_index|
                next if ignore_offense?(line_range)
                next if expected_final_disable?(cop, line_range)
    
    
    Severity: Minor
    Found in lib/rubocop/cop/lint/redundant_cop_disable_directive.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

    There are no issues that match your filters.

    Category
    Status