From 0e5b8fc46bed800a16385d52b2f87db096b4f3a9 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Mon, 18 Dec 2023 04:50:51 -0500 Subject: [PATCH] Fix `Style/RedundantReturn` cop (#28391) --- .rubocop_todo.yml | 9 -------- .../api/v1/directories_controller.rb | 2 +- .../auth/confirmations_controller.rb | 2 +- app/lib/ostatus/tag_manager.rb | 2 +- app/models/form/import.rb | 21 ++++++++++++------- 5 files changed, 16 insertions(+), 20 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5ce0c7876..b8b4895f5 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -426,15 +426,6 @@ Style/RedundantFetchBlock: - 'config/initializers/paperclip.rb' - 'config/puma.rb' -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowMultipleReturnValues. -Style/RedundantReturn: - Exclude: - - 'app/controllers/api/v1/directories_controller.rb' - - 'app/controllers/auth/confirmations_controller.rb' - - 'app/lib/ostatus/tag_manager.rb' - - 'app/models/form/import.rb' - # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. # AllowedMethods: present?, blank?, presence, try, try! diff --git a/app/controllers/api/v1/directories_controller.rb b/app/controllers/api/v1/directories_controller.rb index 35c504a7f..e79b20ce4 100644 --- a/app/controllers/api/v1/directories_controller.rb +++ b/app/controllers/api/v1/directories_controller.rb @@ -12,7 +12,7 @@ class Api::V1::DirectoriesController < Api::BaseController private def require_enabled! - return not_found unless Setting.profile_directory + not_found unless Setting.profile_directory end def set_accounts diff --git a/app/controllers/auth/confirmations_controller.rb b/app/controllers/auth/confirmations_controller.rb index 9f6be9c42..d9cd63090 100644 --- a/app/controllers/auth/confirmations_controller.rb +++ b/app/controllers/auth/confirmations_controller.rb @@ -62,7 +62,7 @@ class Auth::ConfirmationsController < Devise::ConfirmationsController end def captcha_user_bypass? - return true if @confirmation_user.nil? || @confirmation_user.confirmed? + @confirmation_user.nil? || @confirmation_user.confirmed? end def require_unconfirmed! diff --git a/app/lib/ostatus/tag_manager.rb b/app/lib/ostatus/tag_manager.rb index 7d8131622..21b3d3aa5 100644 --- a/app/lib/ostatus/tag_manager.rb +++ b/app/lib/ostatus/tag_manager.rb @@ -52,7 +52,7 @@ class OStatus::TagManager ActivityPub::TagManager.instance.uri_to_local_id(tag) else matches = Regexp.new("objectId=([\\d]+):objectType=#{expected_type}").match(tag) - return matches[1] unless matches.nil? + matches[1] unless matches.nil? end end diff --git a/app/models/form/import.rb b/app/models/form/import.rb index 29a2975c7..712acf370 100644 --- a/app/models/form/import.rb +++ b/app/models/form/import.rb @@ -43,14 +43,19 @@ class Form::Import validate :validate_data def guessed_type - return :muting if csv_headers_match?('Hide notifications') - return :following if csv_headers_match?('Show boosts') || csv_headers_match?('Notify on new posts') || csv_headers_match?('Languages') - return :following if file_name_matches?('follows') || file_name_matches?('following_accounts') - return :blocking if file_name_matches?('blocks') || file_name_matches?('blocked_accounts') - return :muting if file_name_matches?('mutes') || file_name_matches?('muted_accounts') - return :domain_blocking if file_name_matches?('domain_blocks') || file_name_matches?('blocked_domains') - return :bookmarks if file_name_matches?('bookmarks') - return :lists if file_name_matches?('lists') + if csv_headers_match?('Hide notifications') || file_name_matches?('mutes') || file_name_matches?('muted_accounts') + :muting + elsif csv_headers_match?('Show boosts') || csv_headers_match?('Notify on new posts') || csv_headers_match?('Languages') || file_name_matches?('follows') || file_name_matches?('following_accounts') + :following + elsif file_name_matches?('blocks') || file_name_matches?('blocked_accounts') + :blocking + elsif file_name_matches?('domain_blocks') || file_name_matches?('blocked_domains') + :domain_blocking + elsif file_name_matches?('bookmarks') + :bookmarks + elsif file_name_matches?('lists') + :lists + end end # Whether the uploaded CSV file seems to correspond to a different import type than the one selected