Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Layout/LeadingCommentSpace aware of #:nodoc #9964

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1 @@
* [#9964](https://github.com/rubocop/rubocop/pull/9964): Make `Layout/LeadingCommentSpace` aware of `#:nodoc`. ([@koic][])
2 changes: 1 addition & 1 deletion lib/rubocop/cop/layout/leading_comment_space.rb
Expand Up @@ -57,7 +57,7 @@ class LeadingCommentSpace < Base

def on_new_investigation
processed_source.comments.each do |comment|
next unless /\A#+[^#\s=:+-]/.match?(comment.text)
next unless /\A#+[^#\s=+-]/.match?(comment.text)
next if comment.loc.line == 1 && allowed_on_first_line?(comment)
next if doxygen_comment_style?(comment)
next if gemfile_ruby_comment?(comment)
Expand Down
20 changes: 14 additions & 6 deletions spec/rubocop/cop/layout/leading_comment_space_spec.rb
Expand Up @@ -135,12 +135,20 @@
end
end

it 'accepts rdoc syntax' do
expect_no_offenses(<<~RUBY)
#++
#--
#:nodoc:
RUBY
describe 'RDoc syntax' do
it 'does not register an offense when using `#++` or `#--`' do
expect_no_offenses(<<~RUBY)
#++
#--
RUBY
end

it 'registers an offense when starting `:`' do
expect_offense(<<~RUBY)
#:nodoc:
^^^^^^^^ Missing space after `#`.
RUBY
end
end

it 'accepts sprockets directives' do
Expand Down