Class: RuboCop::Cop::Chef::ChefStyle::CommentSentenceSpacing
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Chef::ChefStyle::CommentSentenceSpacing
- 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'.freeze
Instance Method Summary collapse
Instance Method Details
#autocorrect(comment) ⇒ Object
37 38 39 |
# File 'lib/rubocop/cop/chef/style/comment_sentence_spacing.rb', line 37 def autocorrect(comment) ->(corrector) { corrector.replace(comment.loc.expression, comment.text.gsub('. ', '. ').gsub('? ', '? ')) } end |
#investigate(processed_source) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/rubocop/cop/chef/style/comment_sentence_spacing.rb', line 27 def investigate(processed_source) return unless processed_source.ast processed_source.comments.each do |comment| if comment.text.match?(/(.|\?)\s{2}/) # https://rubular.com/r/8o3SiDrQMJSzuU add_offense(comment, location: comment.loc.expression, message: MSG, severity: :refactor) end end end |