-
-
Notifications
You must be signed in to change notification settings - Fork 279
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Expected behavior
I expect this :
params.require(:company_tool).permit(
:salary,
:employees_count,
rows_prices: {
row_total_one_employee: [
:price,
:cell_id
],
row_total_all_employees: [
:price,
:cell_id
]
}
to be autocorrected with :
# Note the double array `[[ ...]]`
params.expect(
company_tool: [:salary,
:employees_count,
rows_prices: [
row_total_one_employee: [[ # double array
:price,
:cell_id
]],
row_total_all_employees: [[
:price,
:cell_id
]]
]
]
)
Actual behavior
it gets autocorrected to this :
params.expect(
company_tool: [:salary,
:employees_count,
{ # unnecessary opening of hash
rows_prices: { # Here it's better to open with `[` than `{` according to docs
row_total_one_employee: [ # no double array
:price,
:cell_id
],
row_total_all_employees: [ # no double array
:price,
:cell_id
]
}
}
]
)
which is false, and make row_prices
empty when provided with an array
Steps to reproduce the problem
To reproduce you can put the examples above in any controller and you will get the same result
Example can also be found here
- https://edgeguides.rubyonrails.org/action_controller_overview.html#nested-parameters
- also example 2 and 3 here can be valuable : https://edgeguides.rubyonrails.org/action_controller_overview.html#examples
RuboCop version
$ [bundle exec] rubocop -V
1.71.0 (using Prism 1.3.0, rubocop-ast 1.37.0, analyzing as Ruby 3.4, running on ruby 3.4.1) [arm64-darwin24]
- rubocop-capybara 2.21.0
- rubocop-factory_bot 2.26.1
- rubocop-graphql 1.5.4
- rubocop-performance 1.23.1
- rubocop-rails 2.29.1
- rubocop-rspec 3.4.0
- rubocop-rspec_rails 2.30.0
dan-manges, andyundso, choznerol, hashimo846 and ajitdsa
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working