Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -53,7 +53,7 @@ class StrongParametersExpect < Base

MSG = 'Use `%<prefer>s` instead.'
RESTRICT_ON_SEND = %i[[] require permit].freeze
PRESENCE_CHECK_METHODS = %i[nil? blank? present?].freeze
PRESENCE_CHECK_METHODS = %i[nil? blank? present? presence].freeze
RAISING_FINDER_METHODS = %i[find find_by! find_sole_by].freeze

minimum_target_rails_version 8.0
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 @@ -43,6 +43,12 @@
RUBY
end

it 'does not register an offense when using `params[:key].presence`' do
expect_no_offenses(<<~RUBY)
params[:key].presence || default
RUBY
end

it 'registers an offense when using `Model.find(params[:id])`' do
expect_offense(<<~RUBY)
Model.find(params[:id])
Expand Down