Sha256: 37ade6a6bb1ccc4d99a787b45570f6f11f64881c2e9f52167ed0ee3fc5f94849
Contents?: true
Size: 1.29 KB
Versions: 5
Compression:
Stored size: 1.29 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) if 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 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
5 entries across 5 versions & 1 rubygems