diff --git a/app/controllers/session_controller.rb b/app/controllers/session_controller.rb index 16aa29c8093..7f93b365fb9 100644 --- a/app/controllers/session_controller.rb +++ b/app/controllers/session_controller.rb @@ -320,7 +320,7 @@ class SessionController < ApplicationController def 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 < ApplicationController end end - return render json: { error: I18n.t('email_login.invalid_token') } + render json: { error: I18n.t('email_login.invalid_token') } rescue ::Webauthn::SecurityKeyError => err invalid_security_key(user, err.message) end diff --git a/app/jobs/regular/bulk_invite.rb b/app/jobs/regular/bulk_invite.rb index 6baa2232d09..a87344f079e 100644 --- a/app/jobs/regular/bulk_invite.rb +++ b/app/jobs/regular/bulk_invite.rb @@ -84,7 +84,7 @@ module Jobs end end - return topic + topic end def send_invite(invite) diff --git a/app/models/reviewable.rb b/app/models/reviewable.rb index 8966621a7ed..13157fa4442 100644 --- a/app/models/reviewable.rb +++ b/app/models/reviewable.rb @@ -228,7 +228,7 @@ class Reviewable < ActiveRecord::Base priority ||= SiteSetting.reviewable_default_visibility id = 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_f end def history diff --git a/app/models/search_log.rb b/app/models/search_log.rb index a3899ff3186..dd0939a3d14 100644 --- a/app/models/search_log.rb +++ b/app/models/search_log.rb @@ -104,7 +104,7 @@ class SearchLog < ActiveRecord::Base details << { 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.rb index dbd6c528628..7d696246ca2 100644 --- a/app/models/user_api_key.rb +++ b/app/models/user_api_key.rb @@ -67,9 +67,9 @@ class UserApiKey < ActiveRecord::Base end def 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) } end end diff --git a/app/serializers/reviewable_serializer.rb b/app/serializers/reviewable_serializer.rb index b2cbdab4592..19c56d330c5 100644 --- a/app/serializers/reviewable_serializer.rb +++ b/app/serializers/reviewable_serializer.rb @@ -115,7 +115,7 @@ class ReviewableSerializer < ApplicationSerializer end def topic_url - return object.topic&.url + object.topic&.url end def include_topic_url? diff --git a/app/services/post_alerter.rb b/app/services/post_alerter.rb index 6784abd2070..7194e0ec696 100644 --- a/app/services/post_alerter.rb +++ b/app/services/post_alerter.rb @@ -249,7 +249,7 @@ class PostAlerter end def should_notify_edit?(notification, opts) - return notification.data_hash["display_username"] != opts[:display_username] + notification.data_hash["display_username"] != opts[:display_username] end def should_notify_like?(user, notification) diff --git a/app/services/site_settings_task.rb b/app/services/site_settings_task.rb index 4cddf6d4dc9..f9d185cdf2f 100644 --- a/app/services/site_settings_task.rb +++ b/app/services/site_settings_task.rb @@ -36,6 +36,6 @@ class SiteSettingsTask counts[:not_found] += 1 end end - return log, counts + [log, counts] end end diff --git a/app/services/themes_install_task.rb b/app/services/themes_install_task.rb index 1a3ac1bbcf3..8466e7b8cb7 100644 --- a/app/services/themes_install_task.rb +++ b/app/services/themes_install_task.rb @@ -25,7 +25,7 @@ class ThemesInstallTask end end - return log, counts + [log, counts] end attr_reader :url, :options diff --git a/lib/auth/github_authenticator.rb b/lib/auth/github_authenticator.rb index b59030fe06e..96fe5bfa7aa 100644 --- a/lib/auth/github_authenticator.rb +++ b/lib/auth/github_authenticator.rb @@ -38,7 +38,7 @@ class Auth::GithubAuthenticator < Auth::Authenticator def valid?() @validator.validate_each(self, :email, @email) - return errors.blank? + errors.blank? end end diff --git a/lib/cooked_post_processor.rb b/lib/cooked_post_processor.rb index 78591ee2548..a59ae11e4f0 100644 --- a/lib/cooked_post_processor.rb +++ b/lib/cooked_post_processor.rb @@ -437,7 +437,7 @@ class CookedPostProcessor def get_filename(upload, src) return File.basename(src) unless upload return upload.original_filename unless upload.original_filename =~ /^blob(\.png)?$/i - return I18n.t("upload.pasted_image_filename") + I18n.t("upload.pasted_image_filename") end def create_node(tag_name, klass) diff --git a/lib/discourse_tagging.rb b/lib/discourse_tagging.rb index 753c1988aff..041170580a2 100644 --- a/lib/discourse_tagging.rb +++ b/lib/discourse_tagging.rb @@ -370,7 +370,7 @@ module DiscourseTagging tag_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] end def 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.rb index 2b1cc0a83cf..130e60070fc 100644 --- a/lib/file_store/s3_store.rb +++ b/lib/file_store/s3_store.rb @@ -55,7 +55,7 @@ module FileStore path, 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] end def remove_file(url, path) diff --git a/lib/freedom_patches/active_record_attribute_methods.rb b/lib/freedom_patches/active_record_attribute_methods.rb index 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 ActiveRecord module ClassMethods # this is for Rails 5 def enforce_raw_sql_whitelist(*args) - return + nil end BLANK_ARRAY = [].freeze @@ -23,7 +23,7 @@ module ActiveRecord def 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_ARRAY end end end diff --git a/lib/guardian.rb b/lib/guardian.rb index d6c996937d0..9920fa89b28 100644 --- a/lib/guardian.rb +++ b/lib/guardian.rb @@ -120,7 +120,7 @@ class Guardian def can_see?(obj) if obj see_method = method_name_for :see, obj - return (see_method ? public_send(see_method, obj) : true) + (see_method ? public_send(see_method, obj) : true) end end @@ -539,7 +539,7 @@ class Guardian def 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) else false end diff --git a/lib/introduction_updater.rb b/lib/introduction_updater.rb index d22f084a639..b6c1a459664 100644 --- a/lib/introduction_updater.rb +++ b/lib/introduction_updater.rb @@ -27,7 +27,7 @@ class IntroductionUpdater protected def summary_from_post(post) - return post ? post.raw.split("\n").first : nil + post ? post.raw.split("\n").first : nil end def find_welcome_post diff --git a/lib/promotion.rb b/lib/promotion.rb index 06977c10fef..3734ab8faae 100644 --- a/lib/promotion.rb +++ b/lib/promotion.rb @@ -103,7 +103,7 @@ class Promotion return false if (stat.time_read / 60) < SiteSetting.tl1_requires_time_spent_mins return false if ((Time.now - user.created_at) / 60) < SiteSetting.tl1_requires_time_spent_mins - return true + true end def self.tl3_met?(user) diff --git a/lib/retrieve_title.rb b/lib/retrieve_title.rb index 90897077223..3c55ec7aecf 100644 --- a/lib/retrieve_title.rb +++ b/lib/retrieve_title.rb @@ -67,6 +67,6 @@ module RetrieveTitle title = extract_title(current) throw :done if title || max_size < current.length end - return title + title end end diff --git a/lib/s3_helper.rb b/lib/s3_helper.rb index 161295202f0..15e137b7606 100644 --- a/lib/s3_helper.rb +++ b/lib/s3_helper.rb @@ -47,7 +47,7 @@ class S3Helper end end - return path, etag.gsub('"', '') + [path, etag.gsub('"', '')] end def remove(s3_filename, copy_to_tombstone = false) diff --git a/lib/unread.rb b/lib/unread.rb index b37dc06ed90..917c2e396d3 100644 --- a/lib/unread.rb +++ b/lib/unread.rb @@ -27,7 +27,7 @@ class Unread new_posts = (highest_post_number - @topic_user.highest_seen_post_number) new_posts = 0 if new_posts < 0 - return new_posts + new_posts end protected diff --git a/script/bulk_import/base.rb b/script/bulk_import/base.rb index 3951f358024..b72104e31c7 100644 --- a/script/bulk_import/base.rb +++ b/script/bulk_import/base.rb @@ -778,7 +778,7 @@ class BulkImport::Base def 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) end end diff --git a/script/import_scripts/discuz_x.rb b/script/import_scripts/discuz_x.rb index 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::Base return nil end - 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::Base return nil end - return upload, real_filename + [upload, real_filename] rescue Mysql2::Error => e puts "SQL Error" puts e.message puts sql - return nil + nil end def first_exists(*items) diff --git a/script/import_scripts/disqus.rb b/script/import_scripts/disqus.rb index cb3679967e9..5dbeb08775a 100644 --- a/script/import_scripts/disqus.rb +++ b/script/import_scripts/disqus.rb @@ -196,7 +196,7 @@ class DisqusSAX < Nokogiri::XML::SAX::Document end def inside?(*params) - return !params.find { |p| !@inside[p] } + !params.find { |p| !@inside[p] } end def normalize diff --git a/script/import_scripts/friendsmegplus.rb b/script/import_scripts/friendsmegplus.rb index 6a53108e82c..cd9c045c3b8 100644 --- a/script/import_scripts/friendsmegplus.rb +++ b/script/import_scripts/friendsmegplus.rb @@ -457,7 +457,7 @@ class ImportScripts::FMGP < ImportScripts::Base end # FIXME: import G+ "+1" as "like" if F+MG+E feature request implemented - return mapped + mapped end def parse_title(post, created_at) @@ -524,7 +524,7 @@ class ImportScripts::FMGP < ImportScripts::Base words << fragment[1] end end - return words + words end def formatted_message(post) @@ -588,10 +588,10 @@ class ImportScripts::FMGP < ImportScripts::Base return text end elsif fragment[0] == 1 - return "\n" + "\n" elsif fragment[0] == 2 urls_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 user if @usermap.include?(fragment[2].to_s) @@ -619,7 +619,7 @@ class ImportScripts::FMGP < ImportScripts::Base end elsif fragment[0] == 4 # hashtag, the octothorpe is included - return fragment[1] + fragment[1] else raise RuntimeError.new("message code #{fragment[0]} not recognized!") end diff --git a/script/import_scripts/lithium.rb b/script/import_scripts/lithium.rb index 83700a87ca4..ac18a3fa36f 100644 --- a/script/import_scripts/lithium.rb +++ b/script/import_scripts/lithium.rb @@ -855,7 +855,7 @@ SQL return nil end - return upload, real_filename + [upload, real_filename] end def post_process_posts diff --git a/script/import_scripts/mybb.rb b/script/import_scripts/mybb.rb index 79b2377edfd..259e855c377 100644 --- a/script/import_scripts/mybb.rb +++ b/script/import_scripts/mybb.rb @@ -181,7 +181,7 @@ class ImportScripts::MyBB < ImportScripts::Base if count > 5 puts "Warning: probably incorrect quote in post #{post_id}" end - return username + username end # Take an original post id and return the migrated topic id and post number for it diff --git a/script/import_scripts/smf2.rb b/script/import_scripts/smf2.rb index 1471d20d3b2..611dabc81bf 100644 --- a/script/import_scripts/smf2.rb +++ b/script/import_scripts/smf2.rb @@ -244,7 +244,7 @@ class ImportScripts::Smf2 < ImportScripts::Base raise "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 + upload rescue SystemCallError => err raise "Attachment for post #{post[:id]} failed: #{err.message}" end @@ -280,7 +280,7 @@ class ImportScripts::Smf2 < ImportScripts::Base return __query(db, sql).to_a if opts[:as] == :array return __query(db, sql, as: :array).first[0] if opts[:as] == :single return __query(db, sql, stream: true).each(&block) if block_given? - return __query(db, sql, stream: true) + __query(db, sql, stream: true) end def __query(db, sql, **opts) @@ -345,7 +345,7 @@ class ImportScripts::Smf2 < ImportScripts::Base end end - return opts[:ignore_quotes] ? body : convert_quotes(body) + opts[:ignore_quotes] ? body : convert_quotes(body) end def get_upload_markdown(upload) diff --git a/script/import_scripts/vbulletin5.rb b/script/import_scripts/vbulletin5.rb index 463d3e4e025..38489314b23 100644 --- a/script/import_scripts/vbulletin5.rb +++ b/script/import_scripts/vbulletin5.rb @@ -359,12 +359,12 @@ class ImportScripts::VBulletin < ImportScripts::Base return nil end - return upload, real_filename + [upload, real_filename] rescue Mysql2::Error => e puts "SQL Error" puts e.message puts sql - return nil + nil end def import_attachments diff --git a/script/memstats.rb b/script/memstats.rb index 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 + m end def 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(' ') end if ARGV.include? '--yaml' diff --git a/spec/models/theme_spec.rb b/spec/models/theme_spec.rb index 749c366f14b..c7fa086adea 100644 --- a/spec/models/theme_spec.rb +++ b/spec/models/theme_spec.rb @@ -267,7 +267,7 @@ HTML def 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] end it "transpiles ES6 code" do