Skip to content

Commit 2a05a21

Browse files
committed
Change from AutoCorrect: false to SafeAutoCorrect: false for Rails/RelativeDateConstant
Follow up to rubocop/rubocop#6177. This `AutoCorrect: false` looks like it was set when there was no way to safe autocorrect by `SafeAutocorrect: false`.
1 parent b2b0e1b commit 2a05a21

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#582](https://github.com/rubocop/rubocop-rails/pull/582): Unmark `AutoCorrect: false` from `Rails/RelativeDateConstant`. ([@koic][])

config/default.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,9 +652,9 @@ Rails/RefuteMethods:
652652
Rails/RelativeDateConstant:
653653
Description: 'Do not assign relative date to constants.'
654654
Enabled: true
655+
SafeAutoCorrect: false
655656
VersionAdded: '0.48'
656-
VersionChanged: '0.59'
657-
AutoCorrect: false
657+
VersionChanged: '2.13'
658658

659659
Rails/RenderInline:
660660
Description: 'Prefer using a template over inline rendering.'

docs/modules/ROOT/pages/cops_rails.adoc

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3728,14 +3728,18 @@ refute_equal true, false
37283728

37293729
| Enabled
37303730
| Yes
3731-
| Yes
3731+
| Yes (Unsafe)
37323732
| 0.48
3733-
| 0.59
3733+
| 2.13
37343734
|===
37353735

37363736
This cop checks whether constant value isn't relative date.
37373737
Because the relative date will be evaluated only once.
37383738

3739+
=== Safety
3740+
3741+
This cop's autocorrection is unsafe because its dependence on the constant is not corrected.
3742+
37393743
=== Examples
37403744

37413745
[source,ruby]
@@ -3762,16 +3766,6 @@ class SomeClass
37623766
end
37633767
----
37643768

3765-
=== Configurable attributes
3766-
3767-
|===
3768-
| Name | Default value | Configurable values
3769-
3770-
| AutoCorrect
3771-
| `false`
3772-
| Boolean
3773-
|===
3774-
37753769
== Rails/RenderInline
37763770

37773771
|===

lib/rubocop/cop/rails/relative_date_constant.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ module Rails
66
# This cop checks whether constant value isn't relative date.
77
# Because the relative date will be evaluated only once.
88
#
9+
# @safety
10+
# This cop's autocorrection is unsafe because its dependence on the constant is not corrected.
11+
#
912
# @example
1013
# # bad
1114
# class SomeClass

0 commit comments

Comments
 (0)