From d9a958fcf7c01462c1235895f0bde7b35c233f45 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 3 May 2023 23:25:43 -0400 Subject: [PATCH] Fix Performance/RedundantMerge cop (#24817) --- .rubocop_todo.yml | 6 ------ config/initializers/paperclip.rb | 12 ++---------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0b076c05dcd..b75d09356e9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -309,12 +309,6 @@ Performance/MapCompact: - 'db/migrate/20200407202420_migrate_unavailable_inboxes.rb' - 'spec/presenters/status_relationships_presenter_spec.rb' -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: MaxKeyValuePairs. -Performance/RedundantMerge: - Exclude: - - 'config/initializers/paperclip.rb' - # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: SafeMultiline. Performance/StartWith: diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb index b72cbe19278..9f0ffc6dc7a 100644 --- a/config/initializers/paperclip.rb +++ b/config/initializers/paperclip.rb @@ -68,11 +68,7 @@ if ENV['S3_ENABLED'] == 'true' } ) - if ENV['S3_PERMISSION'] == '' - Paperclip::Attachment.default_options.merge!( - s3_permissions: ->(*) { nil } - ) - end + Paperclip::Attachment.default_options[:s3_permissions] = ->(*) { nil } if ENV['S3_PERMISSION'] == '' if ENV.has_key?('S3_ENDPOINT') Paperclip::Attachment.default_options[:s3_options].merge!( @@ -90,11 +86,7 @@ if ENV['S3_ENABLED'] == 'true' ) end - if ENV.has_key?('S3_STORAGE_CLASS') - Paperclip::Attachment.default_options[:s3_headers].merge!( - 'X-Amz-Storage-Class' => ENV['S3_STORAGE_CLASS'] - ) - end + Paperclip::Attachment.default_options[:s3_headers]['X-Amz-Storage-Class'] = ENV['S3_STORAGE_CLASS'] if ENV.has_key?('S3_STORAGE_CLASS') # Some S3-compatible providers might not actually be compatible with some APIs # used by kt-paperclip, see https://github.com/mastodon/mastodon/issues/16822