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

Style/CommentedKeyword should be aware of RDoc Directives #6708

Closed
halostatue opened this issue Jan 26, 2019 · 5 comments
Closed

Style/CommentedKeyword should be aware of RDoc Directives #6708

halostatue opened this issue Jan 26, 2019 · 5 comments

Comments

@halostatue
Copy link

The following “comment” is an RDoc directive. It is required to be on the same line as the def.

class Foo
  def initialize # :yields self:
    yield self if block_given?
  end
end

Expected behavior

RuboCop should not warn about commented keywords.

Actual behavior

RuboCop warns about commented keywords.

Steps to reproduce the problem

Run Rubocop over the following code:

class Foo
  def initialize # :yields self:
    yield self if block_given?
  end
end

RuboCop version

0.63.1 (using Parser 2.5.1.0, running on ruby 2.6.0 x86_64-darwin18)

@Drenmi
Copy link
Collaborator

Drenmi commented Feb 5, 2019

Generally we try not to hard code considerations for other libraries into RuboCop, but we do (arbitrarily) make exceptions for popular libraries. Looking at the cop, we're actually already checking for :nodoc:, so it seems reasonable that we'd check for all RDoc directives.

@bquorning
Copy link
Contributor

it seems reasonable that we'd check for all RDoc directives.

In the documentation, the only examples I see of inline comments are for :nodoc: and :yields:. @halostatue Are you aware of whether any other RDoc directive can be used in an inline/trailing comment?

@halostatue
Copy link
Author

Not that I can find in my code. It may be worth noting that # :yields [args]: is only valid after def.

@bquorning
Copy link
Contributor

Proposed fix here: #6735

@koic
Copy link
Member

koic commented Feb 6, 2019

@halostatue I'm looking at the RDoc official document, the example of yields directive looks like # :yields: index, position (not # :yields index, position:).
https://docs.ruby-lang.org/en/2.1.0/RDoc/Markup.html#class-RDoc::Markup-label-Directives

I will merge the proposal #6735 that fix in compliance with the RDoc official document.

BTW, Thanks always for your artifact diff-lcs gem :-)

@koic koic closed this as completed in 500215c Feb 6, 2019
koic added a commit that referenced this issue Feb 6, 2019
[Fix #6708] Style/CommentedKeyword knows :yields:
@Drenmi Drenmi mentioned this issue Feb 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants