Skip to content

Commit

Permalink
Cut 2.13.2
Browse files Browse the repository at this point in the history
  • Loading branch information
koic committed Jan 15, 2022
1 parent 151f4ef commit 14780fd
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## master (unreleased)

## 2.13.2 (2022-01-15)

### New features

* [#614](https://github.com/rubocop/rubocop-rails/pull/614): Add `IgnoreScopes` config option for `Rails/InverseOf` cop. ([@composerinteralia][])
Expand Down
5 changes: 2 additions & 3 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,6 @@ Rails/RedundantPresenceValidationOnBelongsTo:
Enabled: pending
SafeAutoCorrect: false
VersionAdded: '2.13'
VersionChanged: '<<next>>'

Rails/RedundantReceiverInWithOptions:
Description: 'Checks for redundant receiver in `with_options`.'
Expand Down Expand Up @@ -705,15 +704,15 @@ Rails/ReversibleMigration:
Reference: 'https://api.rubyonrails.org/classes/ActiveRecord/Migration/CommandRecorder.html'
Enabled: true
VersionAdded: '0.47'
VersionChanged: '<<next>>'
VersionChanged: '2.13'
Include:
- db/**/*.rb

Rails/ReversibleMigrationMethodDefinition:
Description: 'Checks whether the migration implements either a `change` method or both an `up` and a `down` method.'
Enabled: false
VersionAdded: '2.10'
VersionChanged: '<<next>>'
VersionChanged: '2.13'
Include:
- db/**/*.rb

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: master
version: '2.13'
nav:
- modules/ROOT/nav.adoc
45 changes: 35 additions & 10 deletions docs/modules/ROOT/pages/cops_rails.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ It is unsafe by default because false positives may occur in the
blank check of block arguments to the receiver object.

For example, `[[1, 2], [3, nil]].reject { |first, second| second.blank? }` and
`[[1, 2], [3, nil]].compact_blank` are not compatible. The same is true for `empty?`.
`[[1, 2], [3, nil]].compact_blank` are not compatible. The same is true for `blank?`.
This will work fine when the receiver is a hash object.

=== Examples
Expand All @@ -877,18 +877,14 @@ This will work fine when the receiver is a hash object.
----
# bad
collection.reject(&:blank?)
collection.reject(&:empty?)
collection.reject { |_k, v| v.blank? }
collection.reject { |_k, v| v.empty? }
# good
collection.compact_blank
# bad
collection.reject!(&:blank?)
collection.reject!(&:empty?)
collection.reject! { |_k, v| v.blank? }
collection.reject! { |_k, v| v.empty? }
# good
collection.compact_blank!
Expand Down Expand Up @@ -2504,11 +2500,35 @@ class Patient < ApplicationRecord
end
----

==== IgnoreScopes: false (default)

[source,ruby]
----
# bad
class Blog < ApplicationRecord
has_many :posts, -> { order(published_at: :desc) }
end
----

==== IgnoreScopes: true

[source,ruby]
----
# good
class Blog < ApplicationRecord
has_many :posts, -> { order(published_at: :desc) }
end
----

=== Configurable attributes

|===
| Name | Default value | Configurable values

| IgnoreScopes
| `false`
| Boolean

| Include
| `app/models/**/*.rb`
| Array
Expand Down Expand Up @@ -3574,14 +3594,19 @@ end
| Yes
| Yes (Unsafe)
| 2.13
| -
| 2.13
|===

Since Rails 5.0 the default for `belongs_to` is `optional: false`
unless `config.active_record.belongs_to_required_by_default` is
explicitly set to `false`. The presence validator is added
automatically, and explicit presence validation is redundant.

=== Safety

This cop's autocorrection is unsafe because it changes the default error message
from "can't be blank" to "must exist".

=== Examples

[source,ruby]
Expand Down Expand Up @@ -4057,7 +4082,7 @@ require_dependency 'some_lib'
| Yes
| No
| 0.47
| -
| 2.13
|===

This cop checks whether the change method of the migration file is
Expand Down Expand Up @@ -4255,7 +4280,7 @@ end
| Name | Default value | Configurable values

| Include
| `db/migrate/*.rb`
| `db/**/*.rb`
| Array
|===

Expand All @@ -4273,7 +4298,7 @@ end
| Yes
| No
| 2.10
| -
| 2.13
|===

This cop checks whether the migration implements
Expand Down Expand Up @@ -4326,7 +4351,7 @@ end
| Name | Default value | Configurable values

| Include
| `db/migrate/*.rb`
| `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.13.1'
STRING = '2.13.2'

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

* [#614](https://github.com/rubocop/rubocop-rails/pull/614): Add `IgnoreScopes` config option for `Rails/InverseOf` cop. ([@composerinteralia][])

### Bug fixes

* [#620](https://github.com/rubocop/rubocop-rails/issues/620): Fix a false positive for `Rails/RedundantPresenceValidationOnBelongsTo` using presence with a message. ([@koic][])
* [#626](https://github.com/rubocop/rubocop-rails/issues/626): Fix a false positive for `Rails/CompactBlank` when using the receiver of `blank?` is not a block variable. ([@koic][])
* [#622](https://github.com/rubocop/rubocop-rails/pull/622): Add `month(s)` and `year(s)` to `Rails/DurationArithmetic` cop. ([@agrobbin][])
* [#623](https://github.com/rubocop/rubocop-rails/issues/623): Fix method shadowing check for `Rails/ReadWriteAttribute` cop. ([@nvasilevski][])

### Changes

* [#615](https://github.com/rubocop/rubocop-rails/issues/615): Change `Rails/RedundantPresenceValidationOnBelongsTo` to `SafeAutoCorrect: false`. ([@TonyArra][])
* [#463](https://github.com/rubocop/rubocop-rails/issues/463): Support multiple databases for `ReversibleMigration` and `ReversibleMigrationMethodDefinition` cops. ([@fatkodima][])

[@composerinteralia]: https://github.com/composerinteralia
[@koic]: https://github.com/koic
[@agrobbin]: https://github.com/agrobbin
[@nvasilevski]: https://github.com/nvasilevski
[@TonyArra]: https://github.com/TonyArra
[@fatkodima]: https://github.com/fatkodima

0 comments on commit 14780fd

Please sign in to comment.