Class: RuboCop::CommentConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/monkey_patches/comment_config.rb

Overview

RuboCop >= 1.40.0 introduced a performance fast-path in CommentConfig that skips directive parsing when the raw source does not contain the literal string “rubocop”. Because Cookstyle also supports “# cookstyle:disable” directives, we must also check for “cookstyle” so that those directives are not silently ignored.

Instance Method Summary collapse

Constructor Details

#initialize(processed_source) ⇒ CommentConfig

Returns a new instance of CommentConfig.



12
13
14
15
16
17
18
# File 'lib/rubocop/monkey_patches/comment_config.rb', line 12

def initialize(processed_source)
  original_initialize(processed_source)
  # Re-evaluate @no_directives to also consider "cookstyle" comments
  if @no_directives && processed_source.raw_source.include?('cookstyle')
    @no_directives = false
  end
end

Instance Method Details

#original_initializeObject



10
# File 'lib/rubocop/monkey_patches/comment_config.rb', line 10

alias_method :original_initialize, :initialize