Class: RuboCop::Cop::AnnotationComment
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/rubocop/cop/mixin/annotation_comment.rb |
Overview
Representation of an annotation comment in source code (eg. # TODO: blah blah blah
).
Constant Summary
-
KEYWORDS_REGEX_CACHE =
private
# File 'lib/rubocop/cop/mixin/annotation_comment.rb', line 48{}
Class Method Summary
- .new(comment, keywords) ⇒ AnnotationComment constructor
Instance Attribute Summary
- #annotation? ⇒ Boolean readonly
- #colon readonly
- #comment readonly
- #keyword readonly
- #margin readonly
- #note readonly
- #space readonly
- #just_keyword_of_sentence? ⇒ Boolean readonly private
- #keyword_appearance? ⇒ Boolean readonly private
- #keywords readonly private
Instance Method Summary
-
#bounds
Returns the range bounds for just the annotation.
- #correct?(colon:) ⇒ Boolean
- #regex private
- #split_comment(comment) private
Constructor Details
.new(comment, keywords) ⇒ AnnotationComment
Instance Attribute Details
#annotation? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubocop/cop/mixin/annotation_comment.rb', line 17
def annotation? keyword_appearance? && !just_keyword_of_sentence? end
#colon (readonly)
[ GitHub ]#comment (readonly)
[ GitHub ]
#just_keyword_of_sentence? ⇒ Boolean
(readonly, private)
[ GitHub ]
#keyword (readonly)
[ GitHub ]
#keyword_appearance? ⇒ Boolean
(readonly, private)
[ GitHub ]
#keywords (readonly, private)
[ GitHub ]# File 'lib/rubocop/cop/mixin/annotation_comment.rb', line 37
attr_reader :keywords
#margin (readonly)
[ GitHub ]#note (readonly)
[ GitHub ]#space (readonly)
[ GitHub ]Instance Method Details
#bounds
Returns the range bounds for just the annotation
#correct?(colon:) ⇒ Boolean
#regex (private)
[ GitHub ]# File 'lib/rubocop/cop/mixin/annotation_comment.rb', line 51
def regex KEYWORDS_REGEX_CACHE[keywords] ||= begin keywords_regex = Regexp.new( Regexp.union(keywords.sort_by { |w| -w.length }).source, Regexp::IGNORECASE ) /^(# ?)(\b#{keywords_regex}\b)(\s*:)?(\s+)?(\S+)?/i end end