lib/rubocop/directive_comment.rb in rubocop-1.62.0 vs lib/rubocop/directive_comment.rb in rubocop-1.62.1
- old
+ new
@@ -4,14 +4,16 @@
# This class wraps the `Parser::Source::Comment` object that represents a
# special `rubocop:disable` and `rubocop:enable` comment and exposes what
# cops it contains.
class DirectiveComment
# @api private
- REDUNDANT_DIRECTIVE_COP_DEPARTMENT = 'Lint'
+ LINT_DEPARTMENT = 'Lint'
# @api private
- REDUNDANT_DIRECTIVE_COP = "#{REDUNDANT_DIRECTIVE_COP_DEPARTMENT}/RedundantCopDisableDirective"
+ LINT_REDUNDANT_DIRECTIVE_COP = "#{LINT_DEPARTMENT}/RedundantCopDisableDirective"
# @api private
+ LINT_SYNTAX_COP = "#{LINT_DEPARTMENT}/Syntax"
+ # @api private
COP_NAME_PATTERN = '([A-Z]\w+/)*(?:[A-Z]\w+)'
# @api private
COP_NAMES_PATTERN = "(?:#{COP_NAME_PATTERN} , )*#{COP_NAME_PATTERN}"
# @api private
COPS_PATTERN = "(all|#{COP_NAMES_PATTERN})"
@@ -116,29 +118,29 @@
def splitted_cops_string
(cops || '').split(/,\s*/)
end
def parsed_cop_names
- splitted_cops_string.map do |name|
+ cops = splitted_cops_string.map do |name|
department?(name) ? cop_names_for_department(name) : name
end.flatten
+ cops - [LINT_SYNTAX_COP]
end
def department?(name)
cop_registry.department?(name)
end
def all_cop_names
- exclude_redundant_directive_cop(cop_registry.names)
+ exclude_lint_department_cops(cop_registry.names)
end
def cop_names_for_department(department)
names = cop_registry.names_for_department(department)
- has_redundant_directive_cop = department == REDUNDANT_DIRECTIVE_COP_DEPARTMENT
- has_redundant_directive_cop ? exclude_redundant_directive_cop(names) : names
+ department == LINT_DEPARTMENT ? exclude_lint_department_cops(names) : names
end
- def exclude_redundant_directive_cop(cops)
- cops - [REDUNDANT_DIRECTIVE_COP]
+ def exclude_lint_department_cops(cops)
+ cops - [LINT_REDUNDANT_DIRECTIVE_COP, LINT_SYNTAX_COP]
end
end
end