From 59c8d43d94aa782848bf00f000512a04fca7c069 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Mon, 20 Feb 2023 05:01:20 -0500 Subject: [PATCH] Autofix Rubocop Style/RescueStandardError (#23745) --- .rubocop.yml | 3 +++ .rubocop_todo.yml | 18 ------------------ app/lib/request_pool.rb | 2 +- app/services/import_service.rb | 2 +- lib/mastodon/domains_cli.rb | 2 +- lib/tasks/mastodon.rake | 6 +++--- 6 files changed, 9 insertions(+), 24 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 512c8458f..27d778edf 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -115,6 +115,9 @@ Style/PercentLiteralDelimiters: '%i': '()' '%w': '()' +Style/RescueStandardError: + EnforcedStyle: implicit + Style/TrailingCommaInArrayLiteral: EnforcedStyleForMultiline: 'comma' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f365914cb..bb214a70b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -2234,24 +2234,6 @@ Style/RegexpLiteral: - 'lib/mastodon/premailer_webpack_strategy.rb' - 'lib/tasks/mastodon.rake' -# Offense count: 21 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: implicit, explicit -Style/RescueStandardError: - Exclude: - - 'app/lib/activitypub/activity/move.rb' - - 'app/lib/request.rb' - - 'app/models/account.rb' - - 'app/workers/move_worker.rb' - - 'app/workers/scheduler/vacuum_scheduler.rb' - - 'lib/mastodon/accounts_cli.rb' - - 'lib/mastodon/cli_helper.rb' - - 'lib/mastodon/media_cli.rb' - - 'lib/mastodon/sidekiq_middleware.rb' - - 'lib/mastodon/statuses_cli.rb' - - 'lib/mastodon/upgrade_cli.rb' - # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. diff --git a/app/lib/request_pool.rb b/app/lib/request_pool.rb index e5899a79a..6be172286 100644 --- a/app/lib/request_pool.rb +++ b/app/lib/request_pool.rb @@ -64,7 +64,7 @@ class RequestPool retries += 1 retry end - rescue StandardError + rescue # If this connection raises errors of any kind, it's # better if it gets reaped as soon as possible diff --git a/app/services/import_service.rb b/app/services/import_service.rb index 2f48abc36..7a68e4ca3 100644 --- a/app/services/import_service.rb +++ b/app/services/import_service.rb @@ -114,7 +114,7 @@ class ImportService < BaseService status || ActivityPub::FetchRemoteStatusService.new.call(uri) rescue HTTP::Error, OpenSSL::SSL::SSLError, Mastodon::UnexpectedResponseError nil - rescue StandardError => e + rescue => e Rails.logger.warn "Unexpected error when importing bookmark: #{e}" nil end diff --git a/lib/mastodon/domains_cli.rb b/lib/mastodon/domains_cli.rb index 41ea5b152..05f08f462 100644 --- a/lib/mastodon/domains_cli.rb +++ b/lib/mastodon/domains_cli.rb @@ -165,7 +165,7 @@ module Mastodon stats[domain]['activity'] = Oj.load(res.to_s) end - rescue StandardError + rescue failed.increment ensure processed.increment diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index f919ba989..0a3946ac7 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -92,7 +92,7 @@ namespace :mastodon do prompt.ok 'Database configuration works! 🎆' db_connection_works = true break - rescue StandardError => e + rescue => e prompt.error 'Database connection could not be established with this configuration, try again.' prompt.error e.message break unless prompt.yes?('Try again?') @@ -132,7 +132,7 @@ namespace :mastodon do redis.ping prompt.ok 'Redis configuration works! 🎆' break - rescue StandardError => e + rescue => e prompt.error 'Redis connection could not be established with this configuration, try again.' prompt.error e.message break unless prompt.yes?('Try again?') @@ -417,7 +417,7 @@ namespace :mastodon do mail = ActionMailer::Base.new.mail to: send_to, subject: 'Test', body: 'Mastodon SMTP configuration works!' mail.deliver break - rescue StandardError => e + rescue => e prompt.error 'E-mail could not be sent with this configuration, try again.' prompt.error e.message break unless prompt.yes?('Try again?')