Skip to content

Commit

Permalink
Allow rdoc syntax in leading comment space check
Browse files Browse the repository at this point in the history
rdoc has syntax notations like #--, #++, #:nodoc:, etc.

This fixes #277.
  • Loading branch information
Bozhidar Batsov committed Jun 18, 2013
1 parent d44a66c commit db79146
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rubocop/cop/style/leading_comment_space.rb
Expand Up @@ -8,7 +8,7 @@ class LeadingCommentSpace < Cop

def inspect(source_buffer, source, tokens, ast, comments)
comments.each do |comment|
if comment.text =~ /^#+[^#\s]/
if comment.text =~ /^#+[^#\s:+-]/
unless comment.text.start_with?('#!') && comment.loc.line == 1
add_offence(:convention, comment.loc, MSG)
end
Expand Down
9 changes: 9 additions & 0 deletions spec/rubocop/cops/style/leading_comment_space_spec.rb
Expand Up @@ -50,6 +50,15 @@ module Style
['test', '#!/usr/bin/ruby'])
expect(lcs.offences.size).to eq(1)
end

it 'accepts rdoc syntax' do
inspect_source(lcs,
['#++',
'#--',
'#:nodoc:'])

expect(lcs.offences).to be_empty
end
end
end
end
Expand Down

0 comments on commit db79146

Please sign in to comment.