Sha256: 01bc81d587ab4a05f9684494506c9d39d0095f085b3229f38342dcc610798af0
Contents?: true
Size: 1.13 KB
Versions: 19
Compression:
Stored size: 1.13 KB
Contents
# encoding: utf-8 module RuboCop module Cop module Style # Common functionality related to annotation comments. module AnnotationComment private def annotation?(comment) _margin, first_word, colon, space, note = split_comment(comment) keyword_appearance?(first_word, colon, space) && !just_first_word_of_sentence?(first_word, colon, space, note) end def split_comment(comment) match = comment.text.match(/^(# ?)([A-Za-z]+)(\s*:)?(\s+)?(\S+)?/) return false unless match margin, first_word, colon, space, note = *match.captures [margin, first_word, colon, space, note] end def keyword_appearance?(first_word, colon, space) first_word && keyword?(first_word.upcase) && (colon || space) end def just_first_word_of_sentence?(first_word, colon, space, note) first_word == first_word.capitalize && !colon && space && note end def keyword?(word) config.for_cop('Style/CommentAnnotation')['Keywords'].include?(word) end end end end end
Version data entries
19 entries across 19 versions & 2 rubygems