class RuboCop::Cop::Style::DoubleCopDisableDirective
Detects double disable comments on one line. This is mostly to catch automatically generated comments that need to be regenerated.
@example
# bad def f # rubocop:disable Style/For # rubocop:disable Metrics/AbcSize end # good # rubocop:disable Metrics/AbcSize def f # rubocop:disable Style/For end # rubocop:enable Metrics/AbcSize # if both fit on one line def f # rubocop:disable Style/For, Metrics/AbcSize end
Constants
- MSG
rubocop:enable Style/For, Style/DoubleCopDisableDirective rubocop:enable Lint/RedundantCopDisableDirective, Metrics/AbcSize
Public Instance Methods
on_new_investigation()
click to toggle source
# File lib/rubocop/cop/style/double_cop_disable_directive.rb, line 34 def on_new_investigation processed_source.comments.each do |comment| next unless comment.text.scan(/# rubocop:(?:disable|todo)/).size > 1 add_offense(comment) do |corrector| corrector.replace(comment, comment.text.gsub(%r{ # rubocop:(disable|todo)}, ',')) end end end