lib/rubocop/cop/lint/redundant_cop_disable_directive.rb
Class RedundantCopDisableDirective
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class RedundantCopDisableDirective < Base # rubocop:todo Metrics/ClassLength
include RangeHelp
extend AutoCorrector
COP_NAME = 'Lint/RedundantCopDisableDirective'
Method each_already_disabled
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
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
- 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 each_line_range
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
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)
- 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"