class RuboCop::Cop::Style::CommentAnnotation
to guidelines.
This cop checks that comment annotation keywords are written according
def correct_annotation?(first_word, colon, space, note)
def correct_annotation?(first_word, colon, space, note) keyword?(first_word) && (colon && space && note || !colon && !note) end
def investigate(processed_source)
def investigate(processed_source) processed_source.comments.each do |comment| margin, first_word, colon, space, note = split_comment(comment) next unless annotation?(comment) && !correct_annotation?(first_word, colon, space, note) start = comment.loc.expression.begin_pos + margin.length length = first_word.length + (colon || '').length range = Parser::Source::Range.new(processed_source.buffer, start, start + length) add_offense(nil, range) end end