Class: RuboCop::DirectiveComment
- Inherits:
-
Object
- Object
- RuboCop::DirectiveComment
- Defined in:
- lib/rubocop/monkey_patches/directive_comment.rb
Overview
we're monkey patching the directive marker to allow for "cookstyle: disable whatever" in addition to the "rubocop: disable whatever" that comes with RuboCop.
Everything below the marker is rebuilt exactly the way RuboCop builds it, from RuboCop's own constants, so that directive modes added upstream (push, pop, disable-next, todo-next, ...) keep working here without another patch.
Constant Summary collapse
- DIRECTIVE_MARKER_PATTERN =
'# (?:rubocop|cookstyle) : '- DIRECTIVE_MARKER_REGEXP =
Regexp.new(DIRECTIVE_MARKER_PATTERN.gsub(' ', '\s*'))
- DIRECTIVE_HEADER_PATTERN =
"#{DIRECTIVE_MARKER_PATTERN}((?:#{MODES_PATTERN}))\\b"- DIRECTIVE_COMMENT_REGEXP =
Regexp.new( "#{DIRECTIVE_HEADER_PATTERN}(?:\\s+#{COPS_PATTERN}|\\s+#{PUSH_POP_ARGS_PATTERN})?" .gsub(' ', '\s*') )
- MALFORMED_DIRECTIVE_WITHOUT_COP_NAME_REGEXP =
Regexp.new( "\\A#{DIRECTIVE_HEADER_PATTERN}\\s*\\z".gsub(' ', '\s*') )