Skip to content

Commit e48fec2

Browse files
committed
[Fix #1423] Fix an error for Rails/StrongParametersExpect
This PR fixes an error for `Rails/StrongParametersExpect` when using `permit` with no arguments. Fixes #1423.
1 parent e5dce3a commit e48fec2

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#1423](https://github.com/rubocop/rubocop-rails/issues/1423): Fix an error for `Rails/StrongParametersExpect` when using `permit` with no arguments. ([@koic][])

lib/rubocop/cop/rails/strong_parameters_expect.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class StrongParametersExpect < Base
3232
def_node_matcher :params_require_permit, <<~PATTERN
3333
$(call
3434
$(call
35-
(send nil? :params) :require _) :permit ...)
35+
(send nil? :params) :require _) :permit _+)
3636
PATTERN
3737

3838
def_node_matcher :params_permit_require, <<~PATTERN

spec/rubocop/cop/rails/strong_parameters_expect_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@
136136
RUBY
137137
end
138138

139+
it 'does not register an offense when using `params.require(:target).permit`' do
140+
expect_no_offenses(<<~RUBY)
141+
params.require(:target).permit
142+
RUBY
143+
end
144+
139145
it 'does not register an offense when using `params[:name]`' do
140146
expect_no_offenses(<<~RUBY)
141147
params[:name]

0 commit comments

Comments
 (0)