A platform for community discussion. Free, open, simple.
DEV: Apply Rubocop redundant return style
Penar Musaraj067696df8f95
diff --git a/app/controllers/session_controller.rb b/app/controllers/session_controller.rbindex 16aa29c8093..7f93b365fb9 100644--- a/app/controllers/session_controller.rb+++ b/app/controllers/session_controller.rb@@ -320,7 +320,7 @@ class SessionController < ApplicationControllerdef invalid_security_key(user, err_message = nil)stage_webauthn_security_key_challenge(user) if !params[:security_key_credential]- return render json: failed_json.merge(+ render json: failed_json.merge(error: err_message || I18n.t("login.invalid_security_key"),reason: "invalid_security_key",backup_enabled: user.backup_codes_enabled?@@ -403,7 +403,7 @@ class SessionController < ApplicationControllerendend- return render json: { error: I18n.t('email_login.invalid_token') }+ render json: { error: I18n.t('email_login.invalid_token') }rescue ::Webauthn::SecurityKeyError => errinvalid_security_key(user, err.message)enddiff --git a/app/jobs/regular/bulk_invite.rb b/app/jobs/regular/bulk_invite.rbindex 6baa2232d09..a87344f079e 100644--- a/app/jobs/regular/bulk_invite.rb+++ b/app/jobs/regular/bulk_invite.rb@@ -84,7 +84,7 @@ module Jobsendend- return topic+ topicenddef send_invite(invite)diff --git a/app/models/reviewable.rb b/app/models/reviewable.rbindex 8966621a7ed..13157fa4442 100644--- a/app/models/reviewable.rb+++ b/app/models/reviewable.rb@@ -228,7 +228,7 @@ class Reviewable < ActiveRecord::Basepriority ||= SiteSetting.reviewable_default_visibilityid = Reviewable.priorities[priority.to_sym]return 0.0 if id.nil?- return PluginStore.get('reviewables', "priority_#{id}").to_f+ PluginStore.get('reviewables', "priority_#{id}").to_fenddef historydiff --git a/app/models/search_log.rb b/app/models/search_log.rbindex a3899ff3186..dd0939a3d14 100644--- a/app/models/search_log.rb+++ b/app/models/search_log.rb@@ -104,7 +104,7 @@ class SearchLog < ActiveRecord::Basedetails << { x: Date.parse(record['date'].to_s), y: record['count'] }end- return {+ {type: "search_log_term",title: I18n.t("search_logs.graph_title"),start_date: start_of(period),diff --git a/app/models/user_api_key.rb b/app/models/user_api_key.rbindex dbd6c528628..7d696246ca2 100644--- a/app/models/user_api_key.rb+++ b/app/models/user_api_key.rb@@ -67,9 +67,9 @@ class UserApiKey < ActiveRecord::Baseenddef self.invalid_auth_redirect?(auth_redirect)- return SiteSetting.allowed_user_api_auth_redirects- .split('|')- .none? { |u| WildcardUrlChecker.check_url(u, auth_redirect) }+ SiteSetting.allowed_user_api_auth_redirects+ .split('|')+ .none? { |u| WildcardUrlChecker.check_url(u, auth_redirect) }endenddiff --git a/app/serializers/reviewable_serializer.rb b/app/serializers/reviewable_serializer.rbindex b2cbdab4592..19c56d330c5 100644--- a/app/serializers/reviewable_serializer.rb+++ b/app/serializers/reviewable_serializer.rb@@ -115,7 +115,7 @@ class ReviewableSerializer < ApplicationSerializerenddef topic_url- return object.topic&.url+ object.topic&.urlenddef include_topic_url?diff --git a/app/services/post_alerter.rb b/app/services/post_alerter.rbindex 6784abd2070..7194e0ec696 100644--- a/app/services/post_alerter.rb+++ b/app/services/post_alerter.rb@@ -249,7 +249,7 @@ class PostAlerterenddef should_notify_edit?(notification, opts)- return notification.data_hash["display_username"] != opts[:display_username]+ notification.data_hash["display_username"] != opts[:display_username]enddef should_notify_like?(user, notification)diff --git a/app/services/site_settings_task.rb b/app/services/site_settings_task.rbindex 4cddf6d4dc9..f9d185cdf2f 100644--- a/app/services/site_settings_task.rb+++ b/app/services/site_settings_task.rb@@ -36,6 +36,6 @@ class SiteSettingsTaskcounts[:not_found] += 1endend- return log, counts+ [log, counts]endenddiff --git a/app/services/themes_install_task.rb b/app/services/themes_install_task.rbindex 1a3ac1bbcf3..8466e7b8cb7 100644--- a/app/services/themes_install_task.rb+++ b/app/services/themes_install_task.rb@@ -25,7 +25,7 @@ class ThemesInstallTaskendend- return log, counts+ [log, counts]endattr_reader :url, :optionsdiff --git a/lib/auth/github_authenticator.rb b/lib/auth/github_authenticator.rbindex b59030fe06e..96fe5bfa7aa 100644--- a/lib/auth/github_authenticator.rb+++ b/lib/auth/github_authenticator.rb@@ -38,7 +38,7 @@ class Auth::GithubAuthenticator < Auth::Authenticatordef valid?()@validator.validate_each(self, :email, @email)- return errors.blank?+ errors.blank?endenddiff --git a/lib/cooked_post_processor.rb b/lib/cooked_post_processor.rbindex 78591ee2548..a59ae11e4f0 100644--- a/lib/cooked_post_processor.rb+++ b/lib/cooked_post_processor.rb@@ -437,7 +437,7 @@ class CookedPostProcessordef get_filename(upload, src)return File.basename(src) unless uploadreturn upload.original_filename unless upload.original_filename =~ /^blob(\.png)?$/i- return I18n.t("upload.pasted_image_filename")+ I18n.t("upload.pasted_image_filename")enddef create_node(tag_name, klass)diff --git a/lib/discourse_tagging.rb b/lib/discourse_tagging.rbindex 753c1988aff..041170580a2 100644--- a/lib/discourse_tagging.rb+++ b/lib/discourse_tagging.rb@@ -370,7 +370,7 @@ module DiscourseTaggingtag_names.uniq!end- return opts[:unlimited] ? tag_names : tag_names[0...SiteSetting.max_tags_per_topic]+ opts[:unlimited] ? tag_names : tag_names[0...SiteSetting.max_tags_per_topic]enddef self.add_or_create_tags_by_name(taggable, tag_names_arg, opts = {})diff --git a/lib/file_store/s3_store.rb b/lib/file_store/s3_store.rbindex 2b1cc0a83cf..130e60070fc 100644--- a/lib/file_store/s3_store.rb+++ b/lib/file_store/s3_store.rb@@ -55,7 +55,7 @@ module FileStorepath, etag = @s3_helper.upload(file, path, options)# return the upload url and etag- return File.join(absolute_base_url, path), etag+ [File.join(absolute_base_url, path), etag]enddef remove_file(url, path)diff --git a/lib/freedom_patches/active_record_attribute_methods.rb b/lib/freedom_patches/active_record_attribute_methods.rbindex fbaf5afce61..815159ff4ef 100644--- a/lib/freedom_patches/active_record_attribute_methods.rb+++ b/lib/freedom_patches/active_record_attribute_methods.rb@@ -14,7 +14,7 @@ module ActiveRecordmodule ClassMethods# this is for Rails 5def enforce_raw_sql_whitelist(*args)- return+ nilendBLANK_ARRAY = [].freeze@@ -23,7 +23,7 @@ module ActiveRecorddef disallow_raw_sql!(args, permit: nil)# we may consider moving to https://github.com/rails/rails/pull/33330# once all frozen string hints are in place- return BLANK_ARRAY+ BLANK_ARRAYendendenddiff --git a/lib/guardian.rb b/lib/guardian.rbindex d6c996937d0..9920fa89b28 100644--- a/lib/guardian.rb+++ b/lib/guardian.rb@@ -120,7 +120,7 @@ class Guardiandef can_see?(obj)if objsee_method = method_name_for :see, obj- return (see_method ? public_send(see_method, obj) : true)+ (see_method ? public_send(see_method, obj) : true)endend@@ -539,7 +539,7 @@ class Guardiandef can_do?(action, obj)if obj && authenticated?action_method = method_name_for action, obj- return (action_method ? public_send(action_method, obj) : true)+ (action_method ? public_send(action_method, obj) : true)elsefalseenddiff --git a/lib/introduction_updater.rb b/lib/introduction_updater.rbindex d22f084a639..b6c1a459664 100644--- a/lib/introduction_updater.rb+++ b/lib/introduction_updater.rb@@ -27,7 +27,7 @@ class IntroductionUpdaterprotecteddef summary_from_post(post)- return post ? post.raw.split("\n").first : nil+ post ? post.raw.split("\n").first : nilenddef find_welcome_postdiff --git a/lib/promotion.rb b/lib/promotion.rbindex 06977c10fef..3734ab8faae 100644--- a/lib/promotion.rb+++ b/lib/promotion.rb@@ -103,7 +103,7 @@ class Promotionreturn false if (stat.time_read / 60) < SiteSetting.tl1_requires_time_spent_minsreturn false if ((Time.now - user.created_at) / 60) < SiteSetting.tl1_requires_time_spent_mins- return true+ trueenddef self.tl3_met?(user)diff --git a/lib/retrieve_title.rb b/lib/retrieve_title.rbindex 90897077223..3c55ec7aecf 100644--- a/lib/retrieve_title.rb+++ b/lib/retrieve_title.rb@@ -67,6 +67,6 @@ module RetrieveTitletitle = extract_title(current)throw :done if title || max_size < current.lengthend- return title+ titleendenddiff --git a/lib/s3_helper.rb b/lib/s3_helper.rbindex 161295202f0..15e137b7606 100644--- a/lib/s3_helper.rb+++ b/lib/s3_helper.rb@@ -47,7 +47,7 @@ class S3Helperendend- return path, etag.gsub('"', '')+ [path, etag.gsub('"', '')]enddef remove(s3_filename, copy_to_tombstone = false)diff --git a/lib/unread.rb b/lib/unread.rbindex b37dc06ed90..917c2e396d3 100644--- a/lib/unread.rb+++ b/lib/unread.rb@@ -27,7 +27,7 @@ class Unreadnew_posts = (highest_post_number - @topic_user.highest_seen_post_number)new_posts = 0 if new_posts < 0- return new_posts+ new_postsendprotecteddiff --git a/script/bulk_import/base.rb b/script/bulk_import/base.rbindex 3951f358024..b72104e31c7 100644--- a/script/bulk_import/base.rb+++ b/script/bulk_import/base.rb@@ -778,7 +778,7 @@ class BulkImport::Basedef normalize_charset(text)return text if @encoding == Encoding::UTF_8- return text && text.encode(@encoding).force_encoding(Encoding::UTF_8)+ text && text.encode(@encoding).force_encoding(Encoding::UTF_8)endenddiff --git a/script/import_scripts/discuz_x.rb b/script/import_scripts/discuz_x.rbindex dc8f28ebfe3..2f3e49ee386 100644--- a/script/import_scripts/discuz_x.rb+++ b/script/import_scripts/discuz_x.rb@@ -882,7 +882,7 @@ class ImportScripts::DiscuzX < ImportScripts::Basereturn nilend- return upload, real_filename+ [upload, real_filename]end# find the uploaded file and real name from the db@@ -938,12 +938,12 @@ class ImportScripts::DiscuzX < ImportScripts::Basereturn nilend- return upload, real_filename+ [upload, real_filename]rescue Mysql2::Error => eputs "SQL Error"puts e.messageputs sql- return nil+ nilenddef first_exists(*items)diff --git a/script/import_scripts/disqus.rb b/script/import_scripts/disqus.rbindex cb3679967e9..5dbeb08775a 100644--- a/script/import_scripts/disqus.rb+++ b/script/import_scripts/disqus.rb@@ -196,7 +196,7 @@ class DisqusSAX < Nokogiri::XML::SAX::Documentenddef inside?(*params)- return !params.find { |p| !@inside[p] }+ !params.find { |p| !@inside[p] }enddef normalizediff --git a/script/import_scripts/friendsmegplus.rb b/script/import_scripts/friendsmegplus.rbindex 6a53108e82c..cd9c045c3b8 100644--- a/script/import_scripts/friendsmegplus.rb+++ b/script/import_scripts/friendsmegplus.rb@@ -457,7 +457,7 @@ class ImportScripts::FMGP < ImportScripts::Baseend# FIXME: import G+ "+1" as "like" if F+MG+E feature request implemented- return mapped+ mappedenddef parse_title(post, created_at)@@ -524,7 +524,7 @@ class ImportScripts::FMGP < ImportScripts::Basewords << fragment[1]endend- return words+ wordsenddef formatted_message(post)@@ -588,10 +588,10 @@ class ImportScripts::FMGP < ImportScripts::Basereturn textendelsif fragment[0] == 1- return "\n"+ "\n"elsif fragment[0] == 2urls_seen.add(fragment[2])- return formatted_link_text(fragment[2], fragment[1])+ formatted_link_text(fragment[2], fragment[1])elsif fragment[0] == 3# reference to a userif @usermap.include?(fragment[2].to_s)@@ -619,7 +619,7 @@ class ImportScripts::FMGP < ImportScripts::Baseendelsif fragment[0] == 4# hashtag, the octothorpe is included- return fragment[1]+ fragment[1]elseraise RuntimeError.new("message code #{fragment[0]} not recognized!")enddiff --git a/script/import_scripts/lithium.rb b/script/import_scripts/lithium.rbindex 83700a87ca4..ac18a3fa36f 100644--- a/script/import_scripts/lithium.rb+++ b/script/import_scripts/lithium.rb@@ -855,7 +855,7 @@ SQLreturn nilend- return upload, real_filename+ [upload, real_filename]enddef post_process_postsdiff --git a/script/import_scripts/mybb.rb b/script/import_scripts/mybb.rbindex 79b2377edfd..259e855c377 100644--- a/script/import_scripts/mybb.rb+++ b/script/import_scripts/mybb.rb@@ -181,7 +181,7 @@ class ImportScripts::MyBB < ImportScripts::Baseif count > 5puts "Warning: probably incorrect quote in post #{post_id}"end- return username+ usernameend# Take an original post id and return the migrated topic id and post number for itdiff --git a/script/import_scripts/smf2.rb b/script/import_scripts/smf2.rbindex 1471d20d3b2..611dabc81bf 100644--- a/script/import_scripts/smf2.rb+++ b/script/import_scripts/smf2.rb@@ -244,7 +244,7 @@ class ImportScripts::Smf2 < ImportScripts::Baseraise "Attachment for post #{post[:id]} failed: #{attachment[:filename]}" unless path.present?upload = create_upload(post[:user_id], path, attachment[:filename])raise "Attachment for post #{post[:id]} failed: #{upload.errors.full_messages.join(', ')}" unless upload.persisted?- return upload+ uploadrescue SystemCallError => errraise "Attachment for post #{post[:id]} failed: #{err.message}"end@@ -280,7 +280,7 @@ class ImportScripts::Smf2 < ImportScripts::Basereturn __query(db, sql).to_a if opts[:as] == :arrayreturn __query(db, sql, as: :array).first[0] if opts[:as] == :singlereturn __query(db, sql, stream: true).each(&block) if block_given?- return __query(db, sql, stream: true)+ __query(db, sql, stream: true)enddef __query(db, sql, **opts)@@ -345,7 +345,7 @@ class ImportScripts::Smf2 < ImportScripts::Baseendend- return opts[:ignore_quotes] ? body : convert_quotes(body)+ opts[:ignore_quotes] ? body : convert_quotes(body)enddef get_upload_markdown(upload)diff --git a/script/import_scripts/vbulletin5.rb b/script/import_scripts/vbulletin5.rbindex 463d3e4e025..38489314b23 100644--- a/script/import_scripts/vbulletin5.rb+++ b/script/import_scripts/vbulletin5.rb@@ -359,12 +359,12 @@ class ImportScripts::VBulletin < ImportScripts::Basereturn nilend- return upload, real_filename+ [upload, real_filename]rescue Mysql2::Error => eputs "SQL Error"puts e.messageputs sql- return nil+ nilenddef import_attachmentsdiff --git a/script/memstats.rb b/script/memstats.rbindex 3eff26b8266..f387a883370 100755--- a/script/memstats.rb+++ b/script/memstats.rb@@ -85,7 +85,7 @@ def consume_mapping(map_lines, totals)Mapping::FIELDS.each do |field|totals[field] += m.public_send(field)end- return m+ menddef create_memstats_not_available(totals)@@ -136,7 +136,7 @@ def get_commandline(pid)loop { break if commandline.shift == "-jar" }return "[java] #{commandline.shift}"end- return commandline.join(' ')+ commandline.join(' ')endif ARGV.include? '--yaml'diff --git a/spec/models/theme_spec.rb b/spec/models/theme_spec.rbindex 749c366f14b..c7fa086adea 100644--- a/spec/models/theme_spec.rb+++ b/spec/models/theme_spec.rb@@ -267,7 +267,7 @@ HTMLdef transpile(html)f = ThemeField.create!(target_id: Theme.targets[:mobile], theme_id: 1, name: "after_header", value: html)f.ensure_baked!- return f.value_baked, f.javascript_cache+ [f.value_baked, f.javascript_cache]endit "transpiles ES6 code" do