diff --git a/CHANGELOG.md b/CHANGELOG.md index 2090278142..a25aa8ea2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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][]) diff --git a/config/default.yml b/config/default.yml index 2b0fe90ee4..ad0716eb88 100644 --- a/config/default.yml +++ b/config/default.yml @@ -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.' diff --git a/docs/modules/ROOT/pages/cops_rails.adoc b/docs/modules/ROOT/pages/cops_rails.adoc index 8ccf2e4170..76526bcad8 100644 --- a/docs/modules/ROOT/pages/cops_rails.adoc +++ b/docs/modules/ROOT/pages/cops_rails.adoc @@ -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 diff --git a/lib/rubocop/cop/rails/reflection_class_name.rb b/lib/rubocop/cop/rails/reflection_class_name.rb index 3e70b17b2d..2cd3a0e52b 100644 --- a/lib/rubocop/cop/rails/reflection_class_name.rb +++ b/lib/rubocop/cop/rails/reflection_class_name.rb @@ -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