Sha256: cbb9a388ec8e3df5e73f8e51ecd2b5359fe0cef2b6860e3f16e2ee017ff4733d
Contents?: true
Size: 1.23 KB
Versions: 8
Compression:
Stored size: 1.23 KB
Contents
# encoding: utf-8 module RuboCop module Cop module Style # This cop checks that comment annotation keywords are written according # to guidelines. class CommentAnnotation < Cop include AnnotationComment MSG = 'Annotation keywords should be all upper case, followed by a ' \ 'colon and a space, then a note describing the problem.' 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 private def correct_annotation?(first_word, colon, space, note) keyword?(first_word) && (colon && space && note || !colon && !note) end end end end end
Version data entries
8 entries across 8 versions & 2 rubygems