Skip to content

Commit

Permalink
Merge pull request #1424 from koic/fix_an_error_for_rails_strong_para…
Browse files Browse the repository at this point in the history
…meters_expect

[Fix #1423] Fix an error for `Rails/StrongParametersExpect`
  • Loading branch information
koic authored Jan 20, 2025
2 parents ce69ef7 + e48fec2 commit 158cd38
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#1423](https://github.com/rubocop/rubocop-rails/issues/1423): Fix an error for `Rails/StrongParametersExpect` when using `permit` with no arguments. ([@koic][])
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/strong_parameters_expect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class StrongParametersExpect < Base
def_node_matcher :params_require_permit, <<~PATTERN
$(call
$(call
(send nil? :params) :require _) :permit ...)
(send nil? :params) :require _) :permit _+)
PATTERN

def_node_matcher :params_permit_require, <<~PATTERN
Expand Down
6 changes: 6 additions & 0 deletions spec/rubocop/cop/rails/strong_parameters_expect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@
RUBY
end

it 'does not register an offense when using `params.require(:target).permit`' do
expect_no_offenses(<<~RUBY)
params.require(:target).permit
RUBY
end

it 'does not register an offense when using `params[:name]`' do
expect_no_offenses(<<~RUBY)
params[:name]
Expand Down

0 comments on commit 158cd38

Please sign in to comment.