From bd2988bdf423cc0de242bc22398376b1afd30bf1 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 23 May 2025 03:11:59 -0400 Subject: [PATCH] Fix `Style/PreferredHashMethods` cop (#34775) --- .rubocop_todo.yml | 7 ------- config/initializers/paperclip.rb | 10 +++++----- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 13e2cc3caf..661a01f857 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -70,13 +70,6 @@ Style/OptionalBooleanParameter: - 'app/workers/domain_block_worker.rb' - 'app/workers/unfollow_follow_worker.rb' -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: short, verbose -Style/PreferredHashMethods: - Exclude: - - 'config/initializers/paperclip.rb' - # This cop supports safe autocorrection (--autocorrect). Style/RedundantConstantBase: Exclude: diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb index 6d908fa477..b444c5611b 100644 --- a/config/initializers/paperclip.rb +++ b/config/initializers/paperclip.rb @@ -42,7 +42,7 @@ if ENV['S3_ENABLED'] == 'true' s3_protocol = ENV.fetch('S3_PROTOCOL') { 'https' } s3_hostname = ENV.fetch('S3_HOSTNAME') { "s3-#{s3_region}.amazonaws.com" } - Paperclip::Attachment.default_options[:path] = ENV.fetch('S3_KEY_PREFIX') + "/#{PATH}" if ENV.has_key?('S3_KEY_PREFIX') + Paperclip::Attachment.default_options[:path] = ENV.fetch('S3_KEY_PREFIX') + "/#{PATH}" if ENV.key?('S3_KEY_PREFIX') Paperclip::Attachment.default_options.merge!( storage: :s3, @@ -74,7 +74,7 @@ if ENV['S3_ENABLED'] == 'true' Paperclip::Attachment.default_options[:s3_permissions] = ->(*) {} if ENV['S3_PERMISSION'] == '' - if ENV.has_key?('S3_ENDPOINT') + if ENV.key?('S3_ENDPOINT') Paperclip::Attachment.default_options[:s3_options].merge!( endpoint: ENV['S3_ENDPOINT'], force_path_style: ENV['S3_OVERRIDE_PATH_STYLE'] != 'true' @@ -83,14 +83,14 @@ if ENV['S3_ENABLED'] == 'true' Paperclip::Attachment.default_options[:url] = ':s3_path_url' end - if ENV.has_key?('S3_ALIAS_HOST') || ENV.has_key?('S3_CLOUDFRONT_HOST') + if ENV.key?('S3_ALIAS_HOST') || ENV.key?('S3_CLOUDFRONT_HOST') Paperclip::Attachment.default_options.merge!( url: ':s3_alias_url', s3_host_alias: ENV['S3_ALIAS_HOST'] || ENV['S3_CLOUDFRONT_HOST'] ) end - Paperclip::Attachment.default_options[:s3_headers]['X-Amz-Storage-Class'] = ENV['S3_STORAGE_CLASS'] if ENV.has_key?('S3_STORAGE_CLASS') + Paperclip::Attachment.default_options[:s3_headers]['X-Amz-Storage-Class'] = ENV['S3_STORAGE_CLASS'] if ENV.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 @@ -153,7 +153,7 @@ elsif ENV['AZURE_ENABLED'] == 'true' container: ENV['AZURE_CONTAINER_NAME'], } ) - if ENV.has_key?('AZURE_ALIAS_HOST') + if ENV.key?('AZURE_ALIAS_HOST') Paperclip::Attachment.default_options.merge!( url: ':azure_alias_url', azure_host_alias: ENV['AZURE_ALIAS_HOST']