diff --git a/CHANGELOG.md b/CHANGELOG.md index 3759b88d365..7264bd8f7a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/lib/rubocop/cop/style/commented_keyword.rb b/lib/rubocop/cop/style/commented_keyword.rb index 5bcc0af1cb6..90e54cc57e1 100644 --- a/lib/rubocop/cop/style/commented_keyword.rb +++ b/lib/rubocop/cop/style/commented_keyword.rb @@ -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 @@ -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 diff --git a/manual/cops_style.md b/manual/cops_style.md index c097ca8624a..bf89ddc4048 100644 --- a/manual/cops_style.md +++ b/manual/cops_style.md @@ -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 diff --git a/spec/rubocop/cop/style/commented_keyword_spec.rb b/spec/rubocop/cop/style/commented_keyword_spec.rb index 6190fe4d9a4..32b4d122b2a 100644 --- a/spec/rubocop/cop/style/commented_keyword_spec.rb +++ b/spec/rubocop/cop/style/commented_keyword_spec.rb @@ -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