Skip to content

Commit

Permalink
Cut 2.22.0
Browse files Browse the repository at this point in the history
  • Loading branch information
koic committed Oct 27, 2023
1 parent 962f787 commit ee7e844
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

## master (unreleased)

## 2.22.0 (2023-10-27)

### New features

* [#906](https://github.com/rubocop/rubocop-rails/pull/906): Add `Rails/EnvLocal` cop. ([@sambostock][])
Expand Down
4 changes: 2 additions & 2 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Rails/ActionFilter:
Description: 'Enforces consistent use of action filter methods.'
Enabled: false
VersionAdded: '0.19'
VersionChanged: '<<next>>'
VersionChanged: '2.22'
EnforcedStyle: action
SupportedStyles:
- action
Expand Down Expand Up @@ -433,7 +433,7 @@ Rails/EnumUniqueness:
Rails/EnvLocal:
Description: 'Use `Rails.env.local?` instead of `Rails.env.development? || Rails.env.test?`.'
Enabled: pending
VersionAdded: '<<next>>'
VersionAdded: '2.22'

Rails/EnvironmentComparison:
Description: "Favor `Rails.env.production?` over `Rails.env == 'production'`."
Expand Down
2 changes: 1 addition & 1 deletion docs/antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ name: rubocop-rails
title: RuboCop Rails
# We always provide version without patch here (e.g. 1.1),
# as patch versions should not appear in the docs.
version: ~
version: '2.22'
nav:
- modules/ROOT/nav.adoc
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/cops.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ based on the https://rails.rubystyle.guide/[Rails Style Guide].
* xref:cops_rails.adoc#railseagerevaluationlogmessage[Rails/EagerEvaluationLogMessage]
* xref:cops_rails.adoc#railsenumhash[Rails/EnumHash]
* xref:cops_rails.adoc#railsenumuniqueness[Rails/EnumUniqueness]
* xref:cops_rails.adoc#railsenvlocal[Rails/EnvLocal]
* xref:cops_rails.adoc#railsenvironmentcomparison[Rails/EnvironmentComparison]
* xref:cops_rails.adoc#railsenvironmentvariableaccess[Rails/EnvironmentVariableAccess]
* xref:cops_rails.adoc#railsexit[Rails/Exit]
Expand Down
61 changes: 52 additions & 9 deletions docs/modules/ROOT/pages/cops_rails.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,21 @@ end
|===
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed

| Enabled
| Disabled
| Yes
| Yes
| 0.19
| -
| 2.22
|===

Enforces the consistent use of action filter methods.

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

IMPORTANT: This cop is deprecated. Because the `*_filter` methods were removed in Rails 4.2,
and that Rals version is no longer supported by RuboCop Rails. This cop will be removed in RuboCop Rails 3.0.

=== Examples

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

=== Examples
Expand Down Expand Up @@ -1395,10 +1398,6 @@ def self.published
end
----

=== References

* https://rails.rubystyle.guide#avoid-default-scope

== Rails/Delegate

|===
Expand Down Expand Up @@ -1637,6 +1636,15 @@ has_one :foo
# good
belongs_to :bar
has_one :foo
# bad
belongs_to :foo, class_name: 'Foo'
belongs_to :bar, class_name: 'Foo'
has_one :baz
# good
belongs_to :bar, class_name: 'Foo'
has_one :foo
----

=== Configurable attributes
Expand Down Expand Up @@ -1929,6 +1937,32 @@ enum status: [:active, :archived]
| Array
|===

== Rails/EnvLocal

|===
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed

| Pending
| Yes
| Yes
| 2.22
| -
|===

Checks for usage of `Rails.env.development? || Rails.env.test?` which
can be replaced with `Rails.env.local?`, introduced in Rails 7.1.

=== Examples

[source,ruby]
----
# bad
Rails.env.development? || Rails.env.test?
# good
Rails.env.local?
----

== Rails/EnvironmentComparison

|===
Expand Down Expand Up @@ -3619,8 +3653,13 @@ hash.exclude?(:key)
| 2.20
|===

Checks for add_column call with NOT NULL constraint
in migration file.
Checks for add_column call with NOT NULL constraint in migration file.

`TEXT` can have default values in PostgreSQL, but not in MySQL.
It will automatically detect an adapter from `development` environment
in `config/database.yml` or the environment variable `DATABASE_URL`
when the `Database` option is not set. If the database is MySQL,
this cop ignores offenses for the `TEXT`.

=== Examples

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

| Database
| `<none>`
| `mysql`

| Include
| `+db/**/*.rb+`
| Array
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/rails/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module RuboCop
module Rails
# This module holds the RuboCop Rails version information.
module Version
STRING = '2.21.2'
STRING = '2.22.0'

def self.document_version
STRING.match('\d+\.\d+').to_s
Expand Down
28 changes: 28 additions & 0 deletions relnotes/v2.22.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
### New features

* [#906](https://github.com/rubocop/rubocop-rails/pull/906): Add `Rails/EnvLocal` cop. ([@sambostock][])
* [#1128](https://github.com/rubocop/rubocop-rails/issues/1128): Make `Rails/DuplicateAssociation` aware of duplicate `class_name`. ([@koic][])
* [#1157](https://github.com/rubocop/rubocop-rails/pull/1157): Support some Rails 7.1's new querying methods for `Rails/RedundantActiveRecordAllMethod`. ([@koic][])
* [#1147](https://github.com/rubocop/rubocop-rails/issues/1147): Support the Trilogy adapter for MySQL. ([@koic][])

### Bug fixes

* [#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][])
* [#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][])
* [#1143](https://github.com/rubocop/rubocop-rails/issues/1143): Fix an error for `Rails/RedundantActiveRecordAllMethod` when using RuboCop 1.51 or lower. ([@koic][])
* [#1105](https://github.com/rubocop/rubocop-rails/issues/1105): Fix false positives for `Rails/RedundantPresenceValidationOnBelongsTo` when using `validates` with `:if` or `:unless` options. ([@koic][])
* [#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][])
* [#1160](https://github.com/rubocop/rubocop-rails/issues/1160): Fix `Rails/SaveBang` to ignore parenthesis. ([@fatkodima][])

### Changes

* [#1152](https://github.com/rubocop/rubocop-rails/pull/1152): Add more dangerous column names to `Rails/DangerousColumnNames`. ([@r7kamura][])
* [#1039](https://github.com/rubocop/rubocop-rails/issues/1039): Deprecate `Rails/ActionFilter` cop; it will be disabled by default. ([@koic][])
* [#893](https://github.com/rubocop/rubocop-rails/issues/893): Support `local` as an environment for `Rails/UnknownEnv` from Rails 7.1 onward. ([@ghiculescu][])

[@sambostock]: https://github.com/sambostock
[@koic]: https://github.com/koic
[@samrjenkins]: https://github.com/samrjenkins
[@fatkodima]: https://github.com/fatkodima
[@r7kamura]: https://github.com/r7kamura
[@ghiculescu]: https://github.com/ghiculescu

0 comments on commit ee7e844

Please sign in to comment.