class RuboCop::Cop::Chef::Style::CommentSentenceSpacing

Replaces double spaces between sentences with a single space. Note: This is DISABLED by default.

Constants

MSG

Public Instance Methods

on_new_investigation() click to toggle source
# File lib/rubocop/cop/chef/style/comment_sentence_spacing.rb, line 28
def on_new_investigation
  return unless processed_source.ast

  processed_source.comments.each do |comment|
    next unless comment.text.match?(/(.|\?)\s{2}/) # https://rubular.com/r/8o3SiDrQMJSzuU
    add_offense(comment, location: comment, message: MSG, severity: :refactor) do |corrector|
      corrector.replace(comment, comment.text.gsub('.  ', '. ').gsub('?  ', '? '))
    end
  end
end