Skip to content

Commit aa320da

Browse files
committed
Cut 2.35.0
1 parent 9b730e1 commit aa320da

5 files changed

Lines changed: 114 additions & 11 deletions

File tree

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.35.0 (2026-05-09)
13+
1214
### Bug fixes
1315

1416
* [#1595](https://github.com/rubocop/rubocop-rails/issues/1595): Fix a false negative for `Rails/I18nLocaleTexts` when using `redirect_back_or_to` with a flash message. ([@55728][])

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.35'
66
nav:
77
- modules/ROOT/nav.adoc

docs/modules/ROOT/pages/cops_rails.adoc

Lines changed: 86 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3042,7 +3042,7 @@ get :new, **options
30423042
| Name | Default value | Configurable values
30433043
30443044
| Include
3045-
| `+spec/**/*+`, `+test/**/*+`
3045+
| `+**/spec/**/*+`, `+**/test/**/*+`
30463046
| Array
30473047
|===
30483048
@@ -3303,7 +3303,7 @@ end
33033303
| Name | Default value | Configurable values
33043304
33053305
| Include
3306-
| `+spec/**/*.rb+`, `+test/**/*.rb+`
3306+
| `+**/spec/**/*.rb+`, `+**/test/**/*.rb+`
33073307
| Array
33083308
|===
33093309
@@ -3367,6 +3367,28 @@ class PostsController < ApplicationController
33673367
end
33683368
end
33693369
3370+
# bad
3371+
class PostsController < ApplicationController
3372+
def update
3373+
# ...
3374+
redirect_back_or_to root_path, alert: "Failed to update!"
3375+
end
3376+
end
3377+
3378+
# good
3379+
# config/locales/en.yml
3380+
# en:
3381+
# posts:
3382+
# update:
3383+
# failure: "Failed to update!"
3384+
3385+
class PostsController < ApplicationController
3386+
def update
3387+
# ...
3388+
redirect_back_or_to root_path, alert: t(".failure")
3389+
end
3390+
end
3391+
33703392
# bad
33713393
class UserMailer < ApplicationMailer
33723394
def welcome(user)
@@ -4862,7 +4884,10 @@ a.blank? ? nil : a.foo
48624884
48634885
# good
48644886
a.presence&.foo
4887+
----
48654888
4889+
[source,ruby]
4890+
----
48664891
# good
48674892
a.present? ? a[1] : nil
48684893
@@ -4871,7 +4896,12 @@ a[:key] = value if a.present?
48714896
48724897
# good
48734898
a.present? ? a > 1 : nil
4899+
4900+
# good
48744901
a <= 0 if a.present?
4902+
4903+
# good
4904+
a << "bar" if a.present?
48754905
----
48764906
48774907
[#railspresent]
@@ -5480,7 +5510,7 @@ end
54805510
| Name | Default value | Configurable values
54815511
54825512
| Include
5483-
| `+spec/**/*.rb+`, `+test/**/*.rb+`
5513+
| `+**/spec/**/*.rb+`, `+**/test/**/*.rb+`
54845514
| Array
54855515
|===
54865516
@@ -5867,12 +5897,15 @@ so you still have to use `JSON.parse(response.body)` there.
58675897
----
58685898
# bad
58695899
JSON.parse(response.body)
5870-
5871-
# bad
5900+
Nokogiri::HTML(response.body)
5901+
Nokogiri::HTML4(response.body)
5902+
Nokogiri::HTML5(response.body)
58725903
Nokogiri::HTML.parse(response.body)
5873-
5874-
# bad
5904+
Nokogiri::HTML4.parse(response.body)
58755905
Nokogiri::HTML5.parse(response.body)
5906+
Nokogiri::HTML::Document.parse(response.body)
5907+
Nokogiri::HTML4::Document.parse(response.body)
5908+
Nokogiri::HTML5::Document.parse(response.body)
58765909
58775910
# good
58785911
response.parsed_body
@@ -5885,7 +5918,7 @@ response.parsed_body
58855918
| Name | Default value | Configurable values
58865919
58875920
| Include
5888-
| `+spec/controllers/**/*.rb+`, `+spec/requests/**/*.rb+`, `+test/controllers/**/*.rb+`, `+test/integration/**/*.rb+`
5921+
| `+**/spec/controllers/**/*.rb+`, `+**/spec/requests/**/*.rb+`, `+**/test/controllers/**/*.rb+`, `+**/test/integration/**/*.rb+`
58895922
| Array
58905923
|===
58915924
@@ -6947,6 +6980,15 @@ NOTE: Requires Rails version 8.0
69476980
69486981
Enforces the use of `ActionController::Parameters#expect` as a method for strong parameter handling.
69496982
6983+
In the following cases, `params[:key]` is treated as a key that is expected to be passed from the HTTP client,
6984+
and the cop detects it using the `expect` method.
6985+
6986+
- Method calls on `params[:key]` without comparison methods
6987+
- Passing `params[:key]` as an argument to finder methods that raise on missing records
6988+
- Strong parameter methods using `require` or `permit`
6989+
6990+
Other cases are not detected, as they are cases where `params[:key]` may not be passed from the HTTP client.
6991+
69506992
[#safety-railsstrongparametersexpect]
69516993
=== Safety
69526994
@@ -6960,6 +7002,24 @@ strong parameter conventions.
69607002
69617003
[source,ruby]
69627004
----
7005+
# bad
7006+
params[:key].do_something
7007+
7008+
# good
7009+
params.expect(:key).do_something
7010+
7011+
# bad
7012+
Model.find(params[:id])
7013+
7014+
# good
7015+
Model.find(params.expect(:id))
7016+
7017+
# bad
7018+
Model.find_by!(key: params[:key])
7019+
7020+
# good
7021+
Model.find_by!(key: params.expect(:key))
7022+
69637023
# bad
69647024
params.require(:user).permit(:name, :age)
69657025
params.permit(user: [:name, :age]).require(:user)
@@ -7219,7 +7279,7 @@ end
72197279
| Name | Default value | Configurable values
72207280
72217281
| Include
7222-
| `+spec/**/*.rb+`, `+test/**/*.rb+`
7282+
| `+**/spec/**/*.rb+`, `+**/test/**/*.rb+`
72237283
| Array
72247284
|===
72257285
@@ -7626,10 +7686,27 @@ More can be added to the `Environments` config parameter.
76267686
# bad
76277687
Rails.env.proudction?
76287688
Rails.env == 'proudction'
7689+
Rails.env != 'proudction'
76297690
76307691
# good
76317692
Rails.env.production?
76327693
Rails.env == 'production'
7694+
Rails.env != 'production'
7695+
----
7696+
7697+
[source,ruby]
7698+
----
7699+
# bad
7700+
case Rails.env
7701+
when 'proudction'
7702+
do_something
7703+
end
7704+
7705+
# good
7706+
case Rails.env
7707+
when 'production'
7708+
do_something
7709+
end
76337710
----
76347711
76357712
[#configurable-attributes-railsunknownenv]

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.34.3'
7+
STRING = '2.35.0'
88

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

relnotes/v2.35.0.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
### Bug fixes
2+
3+
* [#1595](https://github.com/rubocop/rubocop-rails/issues/1595): Fix a false negative for `Rails/I18nLocaleTexts` when using `redirect_back_or_to` with a flash message. ([@55728][])
4+
* [#1587](https://github.com/rubocop/rubocop-rails/pull/1587): Fix false positives for `Rails/Presence` with operator methods like `<<`, `=~`, and others. ([@eugeneius][])
5+
* [#1586](https://github.com/rubocop/rubocop-rails/pull/1586): Don't add unnecessary parentheses in `Rails/Presence`. ([@eugeneius][])
6+
* [#1602](https://github.com/rubocop/rubocop-rails/issues/1602): Fix an error in `Rails/SelectMap` when `.select` appears inside a subquery in an argument. ([@koic][])
7+
* [#1604](https://github.com/rubocop/rubocop-rails/pull/1604): Allow `DatabaseTypeResolvable` to fall back to an `adapter` configuration specified in a `shared` key. ([@codergeek121][])
8+
* [#1582](https://github.com/rubocop/rubocop-rails/pull/1582): Fix a false negative where `local` was incorrectly treated as a known environment name when using `==` comparison in `Rails/UnknownEnv`. ([@lovro-bikic][])
9+
10+
### Changes
11+
12+
* [#1571](https://github.com/rubocop/rubocop-rails/pull/1571): Add more detection patterns on `Rails/ResponseParsedBody`. ([@r7kamura][])
13+
* [#1583](https://github.com/rubocop/rubocop-rails/pull/1583): Extend `Rails/StrongParametersExpect` to detect `params[:key]` in method calls and raising finder methods. ([@koic][])
14+
* [#1584](https://github.com/rubocop/rubocop-rails/pull/1584): Add support for `case` statements to `Rails/UnknownEnv`. ([@lovro-bikic][])
15+
* [#1592](https://github.com/rubocop/rubocop-rails/pull/1592): Fix false negative for `!=` comparison in `Rails/UnknownEnv`. ([@lovro-bikic][])
16+
* [#1598](https://github.com/rubocop/rubocop-rails/pull/1598): Use glob patterns compatible with Engine or Packwerk for cops targeting `spec/` and `test/` directories. ([@y-yagi][])
17+
18+
[@55728]: https://github.com/55728
19+
[@eugeneius]: https://github.com/eugeneius
20+
[@koic]: https://github.com/koic
21+
[@codergeek121]: https://github.com/codergeek121
22+
[@lovro-bikic]: https://github.com/lovro-bikic
23+
[@r7kamura]: https://github.com/r7kamura
24+
[@y-yagi]: https://github.com/y-yagi

0 commit comments

Comments
 (0)