Sha256: ef61a0ffe5ebc9aa66c07361201ab4c9e0d87858b75ddde4f36ae3738816effc

Contents?: true

Size: 741 Bytes

Versions: 3

Compression:

Stored size: 741 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # This cop checks whether comments have a leading space
      # after the # denoting the start of the comment. The
      # leading space is not required for some RDoc special syntax,
      # like #++, #--, #:nodoc, etc.
      class LeadingCommentSpace < Cop
        MSG = 'Missing space after #.'

        def inspect(source_buffer, source, tokens, ast, comments)
          comments.each do |comment|
            if comment.text =~ /^#+[^#\s:+-]/
              unless comment.text.start_with?('#!') && comment.loc.line == 1
                add_offence(:convention, comment.loc, MSG)
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
rubocop-0.9.1 lib/rubocop/cop/style/leading_comment_space.rb
sabat-rubocop-0.9.0 lib/rubocop/cop/style/leading_comment_space.rb
rubocop-0.9.0 lib/rubocop/cop/style/leading_comment_space.rb