Sha256: af97ed013c11517756f2a83f77613969e4699a4343d117d9bf60aa1fb6678bdd
Contents?: true
Size: 1.05 KB
Versions: 6840
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true 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 match.captures 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
6,840 entries across 6,815 versions & 28 rubygems