Skip to content

Commit 14780fd

Browse files
committed
Cut 2.13.2
1 parent 151f4ef commit 14780fd

File tree

6 files changed

+63
-15
lines changed

6 files changed

+63
-15
lines changed

CHANGELOG.md

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

33
## master (unreleased)
44

5+
## 2.13.2 (2022-01-15)
6+
57
### New features
68

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

config/default.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,6 @@ Rails/RedundantPresenceValidationOnBelongsTo:
630630
Enabled: pending
631631
SafeAutoCorrect: false
632632
VersionAdded: '2.13'
633-
VersionChanged: '<<next>>'
634633

635634
Rails/RedundantReceiverInWithOptions:
636635
Description: 'Checks for redundant receiver in `with_options`.'
@@ -705,15 +704,15 @@ Rails/ReversibleMigration:
705704
Reference: 'https://api.rubyonrails.org/classes/ActiveRecord/Migration/CommandRecorder.html'
706705
Enabled: true
707706
VersionAdded: '0.47'
708-
VersionChanged: '<<next>>'
707+
VersionChanged: '2.13'
709708
Include:
710709
- db/**/*.rb
711710

712711
Rails/ReversibleMigrationMethodDefinition:
713712
Description: 'Checks whether the migration implements either a `change` method or both an `up` and a `down` method.'
714713
Enabled: false
715714
VersionAdded: '2.10'
716-
VersionChanged: '<<next>>'
715+
VersionChanged: '2.13'
717716
Include:
718717
- db/**/*.rb
719718

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: master
5+
version: '2.13'
66
nav:
77
- modules/ROOT/nav.adoc

docs/modules/ROOT/pages/cops_rails.adoc

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ It is unsafe by default because false positives may occur in the
868868
blank check of block arguments to the receiver object.
869869

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

874874
=== Examples
@@ -877,18 +877,14 @@ This will work fine when the receiver is a hash object.
877877
----
878878
# bad
879879
collection.reject(&:blank?)
880-
collection.reject(&:empty?)
881880
collection.reject { |_k, v| v.blank? }
882-
collection.reject { |_k, v| v.empty? }
883881
884882
# good
885883
collection.compact_blank
886884
887885
# bad
888886
collection.reject!(&:blank?)
889-
collection.reject!(&:empty?)
890887
collection.reject! { |_k, v| v.blank? }
891-
collection.reject! { |_k, v| v.empty? }
892888
893889
# good
894890
collection.compact_blank!
@@ -2504,11 +2500,35 @@ class Patient < ApplicationRecord
25042500
end
25052501
----
25062502

2503+
==== IgnoreScopes: false (default)
2504+
2505+
[source,ruby]
2506+
----
2507+
# bad
2508+
class Blog < ApplicationRecord
2509+
has_many :posts, -> { order(published_at: :desc) }
2510+
end
2511+
----
2512+
2513+
==== IgnoreScopes: true
2514+
2515+
[source,ruby]
2516+
----
2517+
# good
2518+
class Blog < ApplicationRecord
2519+
has_many :posts, -> { order(published_at: :desc) }
2520+
end
2521+
----
2522+
25072523
=== Configurable attributes
25082524

25092525
|===
25102526
| Name | Default value | Configurable values
25112527

2528+
| IgnoreScopes
2529+
| `false`
2530+
| Boolean
2531+
25122532
| Include
25132533
| `app/models/**/*.rb`
25142534
| Array
@@ -3574,14 +3594,19 @@ end
35743594
| Yes
35753595
| Yes (Unsafe)
35763596
| 2.13
3577-
| -
3597+
| 2.13
35783598
|===
35793599

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

3605+
=== Safety
3606+
3607+
This cop's autocorrection is unsafe because it changes the default error message
3608+
from "can't be blank" to "must exist".
3609+
35853610
=== Examples
35863611

35873612
[source,ruby]
@@ -4057,7 +4082,7 @@ require_dependency 'some_lib'
40574082
| Yes
40584083
| No
40594084
| 0.47
4060-
| -
4085+
| 2.13
40614086
|===
40624087

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

42574282
| Include
4258-
| `db/migrate/*.rb`
4283+
| `db/**/*.rb`
42594284
| Array
42604285
|===
42614286

@@ -4273,7 +4298,7 @@ end
42734298
| Yes
42744299
| No
42754300
| 2.10
4276-
| -
4301+
| 2.13
42774302
|===
42784303

42794304
This cop checks whether the migration implements
@@ -4326,7 +4351,7 @@ end
43264351
| Name | Default value | Configurable values
43274352

43284353
| Include
4329-
| `db/migrate/*.rb`
4354+
| `db/**/*.rb`
43304355
| Array
43314356
|===
43324357

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.13.1'
7+
STRING = '2.13.2'
88

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

relnotes/v2.13.2.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
### New features
2+
3+
* [#614](https://github.com/rubocop/rubocop-rails/pull/614): Add `IgnoreScopes` config option for `Rails/InverseOf` cop. ([@composerinteralia][])
4+
5+
### Bug fixes
6+
7+
* [#620](https://github.com/rubocop/rubocop-rails/issues/620): Fix a false positive for `Rails/RedundantPresenceValidationOnBelongsTo` using presence with a message. ([@koic][])
8+
* [#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][])
9+
* [#622](https://github.com/rubocop/rubocop-rails/pull/622): Add `month(s)` and `year(s)` to `Rails/DurationArithmetic` cop. ([@agrobbin][])
10+
* [#623](https://github.com/rubocop/rubocop-rails/issues/623): Fix method shadowing check for `Rails/ReadWriteAttribute` cop. ([@nvasilevski][])
11+
12+
### Changes
13+
14+
* [#615](https://github.com/rubocop/rubocop-rails/issues/615): Change `Rails/RedundantPresenceValidationOnBelongsTo` to `SafeAutoCorrect: false`. ([@TonyArra][])
15+
* [#463](https://github.com/rubocop/rubocop-rails/issues/463): Support multiple databases for `ReversibleMigration` and `ReversibleMigrationMethodDefinition` cops. ([@fatkodima][])
16+
17+
[@composerinteralia]: https://github.com/composerinteralia
18+
[@koic]: https://github.com/koic
19+
[@agrobbin]: https://github.com/agrobbin
20+
[@nvasilevski]: https://github.com/nvasilevski
21+
[@TonyArra]: https://github.com/TonyArra
22+
[@fatkodima]: https://github.com/fatkodima

0 commit comments

Comments
 (0)