Parent

Methods

Files

Class/Module Index [+]

Quicksearch

RuboCop::Cop::Style::CommentAnnotation

This cop checks that comment annotation keywords are written according to guidelines.

Constants

MSG

Public Instance Methods

investigate(processed_source) click to toggle source
# File lib/rubocop/cop/style/comment_annotation.rb, line 13
def investigate(processed_source)
  processed_source.comments.each do |comment|
    margin, first_word, colon, space, note = split_comment(comment)
    next unless 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.