Skip to content

Commit

Permalink
Merge pull request #6735 from bquorning/allow-yields-rdoc-comment
Browse files Browse the repository at this point in the history
[Fix #6708] Style/CommentedKeyword knows :yields:
  • Loading branch information
koic committed Feb 6, 2019
2 parents 91dd462 + 500215c commit 2269afc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -22,6 +22,7 @@

* [#6597](https://github.com/rubocop-hq/rubocop/issues/6597): `Style/LineEndConcatenation` is now known to be unsafe for auto-correct. ([@jaredbeck][])
* [#6725](https://github.com/rubocop-hq/rubocop/issues/6725): Mark `Style/SymbolProc` as unsafe for auto-correct. ([@drenmi][])
* [#6708](https://github.com/rubocop-hq/rubocop/issues/6708): Make `Style/CommentedKeyword` allow the `:yields:` RDoc comment. ([@bquorning][])

## 0.63.1 (2019-01-22)

Expand Down
6 changes: 3 additions & 3 deletions lib/rubocop/cop/style/commented_keyword.rb
Expand Up @@ -6,8 +6,8 @@ module Style
# This cop checks for comments put on the same line as some keywords.
# These keywords are: `begin`, `class`, `def`, `end`, `module`.
#
# Note that some comments (such as `:nodoc:` and `rubocop:disable`) are
# allowed.
# Note that some comments (`:nodoc:`, `:yields:, and `rubocop:disable`)
# are allowed.
#
# @example
# # bad
Expand Down Expand Up @@ -59,7 +59,7 @@ def investigate(processed_source)
private

KEYWORDS = %w[begin class def end module].freeze
ALLOWED_COMMENTS = %w[:nodoc: rubocop:disable].freeze
ALLOWED_COMMENTS = %w[:nodoc: :yields: rubocop:disable].freeze

def offensive?(line)
line = line.lstrip
Expand Down
4 changes: 2 additions & 2 deletions manual/cops_style.md
Expand Up @@ -978,8 +978,8 @@ Enabled | Yes | No | 0.51 | -
This cop checks for comments put on the same line as some keywords.
These keywords are: `begin`, `class`, `def`, `end`, `module`.

Note that some comments (such as `:nodoc:` and `rubocop:disable`) are
allowed.
Note that some comments (`:nodoc:`, `:yields:, and `rubocop:disable`)
are allowed.

### Examples

Expand Down
7 changes: 7 additions & 0 deletions spec/rubocop/cop/style/commented_keyword_spec.rb
Expand Up @@ -122,6 +122,13 @@ class X # :nodoc:
y
end
RUBY
expect_no_offenses(<<-RUBY.strip_indent)
class X
def y # :yields:
yield
end
end
RUBY
expect_no_offenses(<<-RUBY.strip_indent)
def x # rubocop:disable Metrics/MethodLength
y
Expand Down

0 comments on commit 2269afc

Please sign in to comment.