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

[Fix #106] Mark Rails/ReflectionClassName as unsafe #469

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* [#451](https://github.com/rubocop/rubocop-rails/issues/451): Make `Rails/RelativeDateConstant` aware of `yesterday` and `tomorrow` methods. ([@koic][])
* [#454](https://github.com/rubocop/rubocop-rails/pull/454): Mark `Rails/WhereExists` 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 @@ -3163,14 +3163,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