Skip to content

Commit

Permalink
Merge pull request #120 from chef/fix_space_detection
Browse files Browse the repository at this point in the history
Improve detection of double spaces after sentences
  • Loading branch information
tas50 authored Jul 19, 2019
2 parents adb7b01 + c3c028f commit a5fd3f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rubocop/cop/chef/comment_sentence_spacing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ class CommentSentenceSpacing < Cop
def investigate(processed_source)
return unless processed_source.ast
processed_source.comments.each do |comment|
if comment.text.match?(/\. /)
if comment.text.match?(/(.|\?)\s{2}/) # https://rubular.com/r/8o3SiDrQMJSzuU
add_offense(comment, location: comment.loc.expression, message: MSG, severity: :warning)
end
end
end

def autocorrect(comment)
->(corrector) { corrector.replace(comment.loc.expression, comment.text.gsub('. ', '. ')) }
->(corrector) { corrector.replace(comment.loc.expression, comment.text.gsub('. ', '. ').gsub('? ', '? ')) }
end
end
end
Expand Down

0 comments on commit a5fd3f1

Please sign in to comment.