Skip to content

Commit ee7e844

Browse files
committed
Cut 2.22.0
1 parent 962f787 commit ee7e844

File tree

7 files changed

+87
-13
lines changed

7 files changed

+87
-13
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
## master (unreleased)
1111

12+
## 2.22.0 (2023-10-27)
13+
1214
### New features
1315

1416
* [#906](https://github.com/rubocop/rubocop-rails/pull/906): Add `Rails/EnvLocal` cop. ([@sambostock][])

config/default.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Rails/ActionFilter:
9797
Description: 'Enforces consistent use of action filter methods.'
9898
Enabled: false
9999
VersionAdded: '0.19'
100-
VersionChanged: '<<next>>'
100+
VersionChanged: '2.22'
101101
EnforcedStyle: action
102102
SupportedStyles:
103103
- action
@@ -433,7 +433,7 @@ Rails/EnumUniqueness:
433433
Rails/EnvLocal:
434434
Description: 'Use `Rails.env.local?` instead of `Rails.env.development? || Rails.env.test?`.'
435435
Enabled: pending
436-
VersionAdded: '<<next>>'
436+
VersionAdded: '2.22'
437437

438438
Rails/EnvironmentComparison:
439439
Description: "Favor `Rails.env.production?` over `Rails.env == 'production'`."

docs/antora.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ name: rubocop-rails
22
title: RuboCop Rails
33
# We always provide version without patch here (e.g. 1.1),
44
# as patch versions should not appear in the docs.
5-
version: ~
5+
version: '2.22'
66
nav:
77
- modules/ROOT/nav.adoc

docs/modules/ROOT/pages/cops.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ based on the https://rails.rubystyle.guide/[Rails Style Guide].
5454
* xref:cops_rails.adoc#railseagerevaluationlogmessage[Rails/EagerEvaluationLogMessage]
5555
* xref:cops_rails.adoc#railsenumhash[Rails/EnumHash]
5656
* xref:cops_rails.adoc#railsenumuniqueness[Rails/EnumUniqueness]
57+
* xref:cops_rails.adoc#railsenvlocal[Rails/EnvLocal]
5758
* xref:cops_rails.adoc#railsenvironmentcomparison[Rails/EnvironmentComparison]
5859
* xref:cops_rails.adoc#railsenvironmentvariableaccess[Rails/EnvironmentVariableAccess]
5960
* xref:cops_rails.adoc#railsexit[Rails/Exit]

docs/modules/ROOT/pages/cops_rails.adoc

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,21 @@ end
9595
|===
9696
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
9797

98-
| Enabled
98+
| Disabled
9999
| Yes
100100
| Yes
101101
| 0.19
102-
| -
102+
| 2.22
103103
|===
104104

105105
Enforces the consistent use of action filter methods.
106106

107107
The cop is configurable and can enforce the use of the older
108108
something_filter methods or the newer something_action methods.
109109

110+
IMPORTANT: This cop is deprecated. Because the `*_filter` methods were removed in Rails 4.2,
111+
and that Rals version is no longer supported by RuboCop Rails. This cop will be removed in RuboCop Rails 3.0.
112+
110113
=== Examples
111114

112115
==== EnforcedStyle: action (default)
@@ -974,7 +977,7 @@ the PostgreSQL (5.2 later) adapter; thus it will
974977
automatically detect an adapter from `development` environment
975978
in `config/database.yml` or the environment variable `DATABASE_URL`
976979
when the `Database` option is not set.
977-
If the adapter is not `mysql2` or `postgresql`,
980+
If the adapter is not `mysql2`, `trilogy`, or `postgresql`,
978981
this Cop ignores offenses.
979982

980983
=== Examples
@@ -1395,10 +1398,6 @@ def self.published
13951398
end
13961399
----
13971400

1398-
=== References
1399-
1400-
* https://rails.rubystyle.guide#avoid-default-scope
1401-
14021401
== Rails/Delegate
14031402

14041403
|===
@@ -1637,6 +1636,15 @@ has_one :foo
16371636
# good
16381637
belongs_to :bar
16391638
has_one :foo
1639+
1640+
# bad
1641+
belongs_to :foo, class_name: 'Foo'
1642+
belongs_to :bar, class_name: 'Foo'
1643+
has_one :baz
1644+
1645+
# good
1646+
belongs_to :bar, class_name: 'Foo'
1647+
has_one :foo
16401648
----
16411649

16421650
=== Configurable attributes
@@ -1929,6 +1937,32 @@ enum status: [:active, :archived]
19291937
| Array
19301938
|===
19311939

1940+
== Rails/EnvLocal
1941+
1942+
|===
1943+
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
1944+
1945+
| Pending
1946+
| Yes
1947+
| Yes
1948+
| 2.22
1949+
| -
1950+
|===
1951+
1952+
Checks for usage of `Rails.env.development? || Rails.env.test?` which
1953+
can be replaced with `Rails.env.local?`, introduced in Rails 7.1.
1954+
1955+
=== Examples
1956+
1957+
[source,ruby]
1958+
----
1959+
# bad
1960+
Rails.env.development? || Rails.env.test?
1961+
1962+
# good
1963+
Rails.env.local?
1964+
----
1965+
19321966
== Rails/EnvironmentComparison
19331967

19341968
|===
@@ -3619,8 +3653,13 @@ hash.exclude?(:key)
36193653
| 2.20
36203654
|===
36213655

3622-
Checks for add_column call with NOT NULL constraint
3623-
in migration file.
3656+
Checks for add_column call with NOT NULL constraint in migration file.
3657+
3658+
`TEXT` can have default values in PostgreSQL, but not in MySQL.
3659+
It will automatically detect an adapter from `development` environment
3660+
in `config/database.yml` or the environment variable `DATABASE_URL`
3661+
when the `Database` option is not set. If the database is MySQL,
3662+
this cop ignores offenses for the `TEXT`.
36243663

36253664
=== Examples
36263665

@@ -3642,6 +3681,10 @@ add_reference :products, :category, null: false, default: 1
36423681
|===
36433682
| Name | Default value | Configurable values
36443683

3684+
| Database
3685+
| `<none>`
3686+
| `mysql`
3687+
36453688
| Include
36463689
| `+db/**/*.rb+`
36473690
| Array

lib/rubocop/rails/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module RuboCop
44
module Rails
55
# This module holds the RuboCop Rails version information.
66
module Version
7-
STRING = '2.21.2'
7+
STRING = '2.22.0'
88

99
def self.document_version
1010
STRING.match('\d+\.\d+').to_s

relnotes/v2.22.0.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
### New features
2+
3+
* [#906](https://github.com/rubocop/rubocop-rails/pull/906): Add `Rails/EnvLocal` cop. ([@sambostock][])
4+
* [#1128](https://github.com/rubocop/rubocop-rails/issues/1128): Make `Rails/DuplicateAssociation` aware of duplicate `class_name`. ([@koic][])
5+
* [#1157](https://github.com/rubocop/rubocop-rails/pull/1157): Support some Rails 7.1's new querying methods for `Rails/RedundantActiveRecordAllMethod`. ([@koic][])
6+
* [#1147](https://github.com/rubocop/rubocop-rails/issues/1147): Support the Trilogy adapter for MySQL. ([@koic][])
7+
8+
### Bug fixes
9+
10+
* [#952](https://github.com/rubocop/rubocop-rails/issues/952): Fix a false positive for `Rails/NotNullColumn` when using `null: false` for MySQL's TEXT type. ([@koic][])
11+
* [#1041](https://github.com/rubocop/rubocop-rails/issues/1041): Fix a false positive for `Rails/Output` when output method is called with block argument. ([@koic][])
12+
* [#1143](https://github.com/rubocop/rubocop-rails/issues/1143): Fix an error for `Rails/RedundantActiveRecordAllMethod` when using RuboCop 1.51 or lower. ([@koic][])
13+
* [#1105](https://github.com/rubocop/rubocop-rails/issues/1105): Fix false positives for `Rails/RedundantPresenceValidationOnBelongsTo` when using `validates` with `:if` or `:unless` options. ([@koic][])
14+
* [#1158](https://github.com/rubocop/rubocop-rails/issues/1158): `Rails/HasManyOrHasOneDependent` does not add offence when has_many or has_one is called on an explicit receiver. ([@samrjenkins][])
15+
* [#1160](https://github.com/rubocop/rubocop-rails/issues/1160): Fix `Rails/SaveBang` to ignore parenthesis. ([@fatkodima][])
16+
17+
### Changes
18+
19+
* [#1152](https://github.com/rubocop/rubocop-rails/pull/1152): Add more dangerous column names to `Rails/DangerousColumnNames`. ([@r7kamura][])
20+
* [#1039](https://github.com/rubocop/rubocop-rails/issues/1039): Deprecate `Rails/ActionFilter` cop; it will be disabled by default. ([@koic][])
21+
* [#893](https://github.com/rubocop/rubocop-rails/issues/893): Support `local` as an environment for `Rails/UnknownEnv` from Rails 7.1 onward. ([@ghiculescu][])
22+
23+
[@sambostock]: https://github.com/sambostock
24+
[@koic]: https://github.com/koic
25+
[@samrjenkins]: https://github.com/samrjenkins
26+
[@fatkodima]: https://github.com/fatkodima
27+
[@r7kamura]: https://github.com/r7kamura
28+
[@ghiculescu]: https://github.com/ghiculescu

0 commit comments

Comments
 (0)