Class: RuboCop::Cop::Chef::Style::CommentSentenceSpacing
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/chef/style/comment_sentence_spacing.rb
Overview
Replaces double spaces between sentences with a single space. Note: This is DISABLED by default.
Constant Summary collapse
- MSG =
'Use a single space after sentences in comments'
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#on_new_investigation ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# 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, severity: :refactor) do |corrector| corrector.replace(comment, comment.text.gsub('. ', '. ').gsub('? ', '? ')) end end end |