lib/rubocop/comment_config.rb in rubocop-0.68.1 vs lib/rubocop/comment_config.rb in rubocop-0.69.0
- old
+ new
@@ -2,15 +2,15 @@
module RuboCop
# This class parses the special `rubocop:disable` comments in a source
# and provides a way to check if each cop is enabled at arbitrary line.
class CommentConfig
- UNNEEDED_DISABLE = 'Lint/UnneededCopDisableDirective'.freeze
+ UNNEEDED_DISABLE = 'Lint/UnneededCopDisableDirective'
- COP_NAME_PATTERN = '([A-Z]\w+/)?(?:[A-Z]\w+)'.freeze
- COP_NAMES_PATTERN = "(?:#{COP_NAME_PATTERN} , )*#{COP_NAME_PATTERN}".freeze
- COPS_PATTERN = "(all|#{COP_NAMES_PATTERN})".freeze
+ COP_NAME_PATTERN = '([A-Z]\w+/)?(?:[A-Z]\w+)'
+ COP_NAMES_PATTERN = "(?:#{COP_NAME_PATTERN} , )*#{COP_NAME_PATTERN}"
+ COPS_PATTERN = "(all|#{COP_NAMES_PATTERN})"
COMMENT_DIRECTIVE_REGEXP = Regexp.new(
('# rubocop : ((?:dis|en)able)\b ' + COPS_PATTERN).gsub(' ', '\s*')
)
@@ -173,11 +173,11 @@
end
def handle_enable_all(names, extras, comment)
enabled_cops = 0
names.each do |name, counter|
- next unless counter > 0
+ next unless counter.positive?
names[name] -= 1
enabled_cops += 1
end
@@ -187,10 +187,10 @@
def handle_switch(cop_names, names, disabled, extras, comment)
cop_names.each do |name|
names[name] ||= 0
if disabled
names[name] += 1
- elsif names[name] > 0
+ elsif (names[name]).positive?
names[name] -= 1
else
extras << [comment, name]
end
end