class RuboCop::Cop::Style::DoubleCopDisableDirective
end
def f # rubocop:disable Style/For, Metrics/AbcSize
# if both fit on one line
# rubocop:enable Metrics/AbcSize
end
def f # rubocop:disable Style/For
# rubocop:disable Metrics/AbcSize
# good
end
def f # rubocop:disable Style/For # rubocop:disable Metrics/AbcSize
# bad
@example
automatically generated comments that need to be regenerated.
Detects double disable comments on one line. This is mostly to catch
def autocorrect(comment)
def autocorrect(comment) prefix = if comment.text.start_with?('# rubocop:disable') '# rubocop:disable' else '# rubocop:todo' end lambda do |corrector| corrector.replace(comment.loc.expression, comment.text[/#{prefix} \S+/]) end end
def investigate(processed_source)
def investigate(processed_source) processed_source.comments.each do |comment| next unless comment.text.scan(/# rubocop:(?:disable|todo)/).size > 1 add_offense(comment) end end