Sha256: 4ac8d7e89ec94502f8029de7e92701c8e3f8303df4799bb0135c0a38e68f7333
Contents?: true
Size: 1.16 KB
Versions: 50
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Style # Common functionality related to annotation comments. module AnnotationComment private # @api public 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 # @api public def split_comment(comment) match = comment.text.match(/^(# ?)([A-Za-z]+)(\s*:)?(\s+)?(\S+)?/) return false unless match match.captures end # @api public def keyword_appearance?(first_word, colon, space) first_word && keyword?(first_word.upcase) && (colon || space) end # @api private def just_first_word_of_sentence?(first_word, colon, space, note) first_word == first_word.capitalize && !colon && space && note end # @api public def keyword?(word) config.for_cop('Style/CommentAnnotation')['Keywords'].include?(word) end end end end end
Version data entries
50 entries across 50 versions & 5 rubygems