Skip to content

Files

Latest commit

 

History

History
56 lines (43 loc) · 1.18 KB

Lint-MissingCopEnableDirective.md

File metadata and controls

56 lines (43 loc) · 1.18 KB

Pattern: Missing cop enable directive

Issue: -

Description

This rule checks that there is an # rubocop:enable ... statement after a # rubocop:disable ... statement. This will prevent leaving cop disables on wide ranges of code, that latter contributors to a file wouldn't be aware of.

Examples

# Lint/MissingCopEnableDirective:
#   MaximumRangeSize: .inf

# good
# rubocop:disable Layout/SpaceAroundOperators
x= 0
# rubocop:enable Layout/SpaceAroundOperators
# y = 1
# EOF

# bad
# rubocop:disable Layout/SpaceAroundOperators
x= 0
# EOF
# Lint/MissingCopEnableDirective:
#   MaximumRangeSize: 2

# good
# rubocop:disable Layout/SpaceAroundOperators
x= 0
# With the previous, there are 2 lines on which cop is disabled.
# rubocop:enable Layout/SpaceAroundOperators

# bad
# rubocop:disable Layout/SpaceAroundOperators
x= 0
x += 1
# Including this, that's 3 lines on which the cop is disabled.
# rubocop:enable Layout/SpaceAroundOperators

Default configuration

Attribute Value
MaximumRangeSize Infinity

Further Reading