Skip to content

Commit

Permalink
Merge pull request #469 from koic/mark_rails_reflection_class_name_as…
Browse files Browse the repository at this point in the history
…_unsafe

[Fix #106] Mark `Rails/ReflectionClassName` as unsafe
  • Loading branch information
koic authored Apr 28, 2021
2 parents 436009e + c9d6e7e commit 66d1a6b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* [#454](https://github.com/rubocop/rubocop-rails/pull/454): Mark `Rails/WhereExists` as unsafe auto-correction. ([@koic][])
* [#403](https://github.com/rubocop/rubocop-rails/pull/403): Mark `Rails/WhereEquals` as unsafe auto-correction. ([@koic][])
* [#379](https://github.com/rubocop/rubocop-rails/issues/379): Mark `Rails/DynamicFindBy` as unsafe. ([@koic][])
* [#106](https://github.com/rubocop/rubocop-rails/issues/106): Mark `Rails/ReflectionClassName` as unsafe. ([@koic][])
* [#456](https://github.com/rubocop/rubocop-rails/pull/456): Drop Ruby 2.4 support. ([@koic][])
* [#462](https://github.com/rubocop/rubocop-rails/pull/462): Require RuboCop 1.7 or higher. ([@koic][])

Expand Down
2 changes: 2 additions & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,9 @@ Rails/RedundantReceiverInWithOptions:
Rails/ReflectionClassName:
Description: 'Use a string for `class_name` option value in the definition of a reflection.'
Enabled: true
Safe: false
VersionAdded: '0.64'
VersionChanged: '2.10'

Rails/RefuteMethods:
Description: 'Use `assert_not` methods instead of `refute` methods.'
Expand Down
6 changes: 4 additions & 2 deletions docs/modules/ROOT/pages/cops_rails.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3164,14 +3164,16 @@ end
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged

| Enabled
| Yes
| No
| No
| 0.64
| -
| 2.10
|===

This cop checks if the value of the option `class_name`, in
the definition of a reflection is a string.
It is marked as unsafe because it cannot be determined whether
constant or method return value specified to `class_name` is a string.

=== Examples

Expand Down
2 changes: 2 additions & 0 deletions lib/rubocop/cop/rails/reflection_class_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module Cop
module Rails
# This cop checks if the value of the option `class_name`, in
# the definition of a reflection is a string.
# It is marked as unsafe because it cannot be determined whether
# constant or method return value specified to `class_name` is a string.
#
# @example
# # bad
Expand Down

0 comments on commit 66d1a6b

Please sign in to comment.