Skip to content

Commit

Permalink
Cut 2.29.0
Browse files Browse the repository at this point in the history
  • Loading branch information
koic committed Jan 18, 2025
1 parent 72a9281 commit 983f264
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 4 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.29.0 (2025-01-18)

### New features

* [#1407](https://github.com/rubocop/rubocop-rails/pull/1407): Add new `Rails/MultipleRoutePaths` cop. ([@koic][])
Expand Down
4 changes: 2 additions & 2 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ Rails/MultipleRoutePaths:
Description: 'Checks for mapping a route with multiple paths, which is deprecated and will be removed in Rails 8.1.'
Enabled: pending
Severity: warning
VersionAdded: '<<next>>'
VersionAdded: '2.29'
Include:
- config/routes.rb
- config/routes/**/*.rb
Expand Down Expand Up @@ -1088,7 +1088,7 @@ Rails/StrongParametersExpect:
Include:
- app/controllers/**/*.rb
SafeAutoCorrect: false
VersionAdded: '<<next>>'
VersionAdded: '2.29'

Rails/TableNameAssignment:
Description: >-
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.29'
nav:
- modules/ROOT/nav.adoc
2 changes: 2 additions & 0 deletions docs/modules/ROOT/pages/cops.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ based on the https://rails.rubystyle.guide/[Rails Style Guide].
* xref:cops_rails.adoc#railsmailername[Rails/MailerName]
* xref:cops_rails.adoc#railsmatchroute[Rails/MatchRoute]
* xref:cops_rails.adoc#railsmigrationclassname[Rails/MigrationClassName]
* xref:cops_rails.adoc#railsmultipleroutepaths[Rails/MultipleRoutePaths]
* xref:cops_rails.adoc#railsnegateinclude[Rails/NegateInclude]
* xref:cops_rails.adoc#railsnotnullcolumn[Rails/NotNullColumn]
* xref:cops_rails.adoc#railsorderbyid[Rails/OrderById]
Expand Down Expand Up @@ -127,6 +128,7 @@ based on the https://rails.rubystyle.guide/[Rails Style Guide].
* xref:cops_rails.adoc#railsskipsmodelvalidations[Rails/SkipsModelValidations]
* xref:cops_rails.adoc#railssquishedsqlheredocs[Rails/SquishedSQLHeredocs]
* xref:cops_rails.adoc#railsstripheredoc[Rails/StripHeredoc]
* xref:cops_rails.adoc#railsstrongparametersexpect[Rails/StrongParametersExpect]
* xref:cops_rails.adoc#railstablenameassignment[Rails/TableNameAssignment]
* xref:cops_rails.adoc#railsthreestatebooleancolumn[Rails/ThreeStateBooleanColumn]
* xref:cops_rails.adoc#railstimezone[Rails/TimeZone]
Expand Down
97 changes: 97 additions & 0 deletions docs/modules/ROOT/pages/cops_rails.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3975,6 +3975,49 @@ end
| Array
|===
[#railsmultipleroutepaths]
== Rails/MultipleRoutePaths
|===
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
| Pending
| Yes
| Always
| 2.29
| -
|===
Checks for mapping a route with multiple paths, which is deprecated and will be removed in Rails 8.1.
[#examples-railsmultipleroutepaths]
=== Examples
[source,ruby]
----
# bad
get '/users', '/other_path', to: 'users#index'
# good
get '/users', to: 'users#index'
get '/other_path', to: 'users#index'
----
[#configurable-attributes-railsmultipleroutepaths]
=== Configurable attributes
|===
| Name | Default value | Configurable values
| Severity
| `warning`
| String
| Include
| `config/routes.rb`, `+config/routes/**/*.rb+`
| Array
|===
[#railsnegateinclude]
== Rails/NegateInclude
Expand Down Expand Up @@ -6602,6 +6645,60 @@ EOS
* https://rails.rubystyle.guide/#prefer-squiggly-heredoc
[#railsstrongparametersexpect]
== Rails/StrongParametersExpect
NOTE: Required Rails version: 8.0
|===
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
| Pending
| Yes
| Always (Unsafe)
| 2.29
| -
|===
Enforces the use of `ActionController::Parameters#expect` as a method for strong parameter handling.
[#safety-railsstrongparametersexpect]
=== Safety
This cop's autocorrection is considered unsafe because there are cases where the HTTP status may change
from 500 to 400 when handling invalid parameters. This change, however, reflects an intentional
incompatibility introduced for valid reasons by the `expect` method, which aligns better with
strong parameter conventions.
[#examples-railsstrongparametersexpect]
=== Examples
[source,ruby]
----
# bad
params.require(:user).permit(:name, :age)
params.permit(user: [:name, :age]).require(:user)
# good
params.expect(user: [:name, :age])
----
[#configurable-attributes-railsstrongparametersexpect]
=== Configurable attributes
|===
| Name | Default value | Configurable values
| Include
| `+app/controllers/**/*.rb+`
| Array
|===
[#references-railsstrongparametersexpect]
=== References
* https://api.rubyonrails.org/classes/ActionController/Parameters.html#method-i-expect
[#railstablenameassignment]
== Rails/TableNameAssignment
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.28.0'
STRING = '2.29.0'

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

* [#1407](https://github.com/rubocop/rubocop-rails/pull/1407): Add new `Rails/MultipleRoutePaths` cop. ([@koic][])
* [#1358](https://github.com/rubocop/rubocop-rails/issues/1358): Add new `Rails/StrongParametersExpect` cop. ([@koic][])

### Bug fixes

* [#1409](https://github.com/rubocop/rubocop-rails/pull/1409): Fix an error for `Rails/ReversibleMigration` when calling `drop_table` without any arguments. ([@earlopain][])
* [#1397](https://github.com/rubocop/rubocop-rails/pull/1397): Fix an incorrect autocorrect for `Rails/TimeZone` when Time.new has a string argument. ([@mterada1228][])
* [#1406](https://github.com/rubocop/rubocop-rails/pull/1406): Fix autocorrection for `Rails/IndexBy` and `Rails/IndexWith` when `map { ... }.to_h` is enclosed in another block. ([@franzliedke][], [@eugeneius][])
* [#1404](https://github.com/rubocop/rubocop-rails/pull/1404): Update `Rails/IndexBy` and `Rails/IndexWith` to support numbered block parameters. ([@eugeneius][])
* [#1405](https://github.com/rubocop/rubocop-rails/pull/1405): Fix autocorrection for `Rails/IndexWith` when the value is a hash literal without braces. ([@koic][], [@eugeneius][])
* [#1414](https://github.com/rubocop/rubocop-rails/pull/1414): Fix `Rails/HttpPositionalArguments` cop false positives with arguments forwarding. ([@viralpraxis][])

### Changes

* [#1410](https://github.com/rubocop/rubocop-rails/issues/1410): Make registered cops aware of `AllCops: MigratedSchemaVersion`. ([@koic][])

[@koic]: https://github.com/koic
[@earlopain]: https://github.com/earlopain
[@mterada1228]: https://github.com/mterada1228
[@franzliedke]: https://github.com/franzliedke
[@eugeneius]: https://github.com/eugeneius
[@viralpraxis]: https://github.com/viralpraxis

0 comments on commit 983f264

Please sign in to comment.