mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 16:02:46 +08:00
DEV: Apply Rubocop redundant return style
This commit is contained in:
parent
be15abcf7f
commit
067696df8f
|
@ -320,7 +320,7 @@ class SessionController < ApplicationController
|
||||||
|
|
||||||
def invalid_security_key(user, err_message = nil)
|
def invalid_security_key(user, err_message = nil)
|
||||||
stage_webauthn_security_key_challenge(user) if !params[:security_key_credential]
|
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"),
|
error: err_message || I18n.t("login.invalid_security_key"),
|
||||||
reason: "invalid_security_key",
|
reason: "invalid_security_key",
|
||||||
backup_enabled: user.backup_codes_enabled?
|
backup_enabled: user.backup_codes_enabled?
|
||||||
|
@ -403,7 +403,7 @@ class SessionController < ApplicationController
|
||||||
end
|
end
|
||||||
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
|
rescue ::Webauthn::SecurityKeyError => err
|
||||||
invalid_security_key(user, err.message)
|
invalid_security_key(user, err.message)
|
||||||
end
|
end
|
||||||
|
|
|
@ -84,7 +84,7 @@ module Jobs
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return topic
|
topic
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_invite(invite)
|
def send_invite(invite)
|
||||||
|
|
|
@ -228,7 +228,7 @@ class Reviewable < ActiveRecord::Base
|
||||||
priority ||= SiteSetting.reviewable_default_visibility
|
priority ||= SiteSetting.reviewable_default_visibility
|
||||||
id = Reviewable.priorities[priority.to_sym]
|
id = Reviewable.priorities[priority.to_sym]
|
||||||
return 0.0 if id.nil?
|
return 0.0 if id.nil?
|
||||||
return PluginStore.get('reviewables', "priority_#{id}").to_f
|
PluginStore.get('reviewables', "priority_#{id}").to_f
|
||||||
end
|
end
|
||||||
|
|
||||||
def history
|
def history
|
||||||
|
|
|
@ -104,7 +104,7 @@ class SearchLog < ActiveRecord::Base
|
||||||
details << { x: Date.parse(record['date'].to_s), y: record['count'] }
|
details << { x: Date.parse(record['date'].to_s), y: record['count'] }
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
{
|
||||||
type: "search_log_term",
|
type: "search_log_term",
|
||||||
title: I18n.t("search_logs.graph_title"),
|
title: I18n.t("search_logs.graph_title"),
|
||||||
start_date: start_of(period),
|
start_date: start_of(period),
|
||||||
|
|
|
@ -67,9 +67,9 @@ class UserApiKey < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.invalid_auth_redirect?(auth_redirect)
|
def self.invalid_auth_redirect?(auth_redirect)
|
||||||
return SiteSetting.allowed_user_api_auth_redirects
|
SiteSetting.allowed_user_api_auth_redirects
|
||||||
.split('|')
|
.split('|')
|
||||||
.none? { |u| WildcardUrlChecker.check_url(u, auth_redirect) }
|
.none? { |u| WildcardUrlChecker.check_url(u, auth_redirect) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ class ReviewableSerializer < ApplicationSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def topic_url
|
def topic_url
|
||||||
return object.topic&.url
|
object.topic&.url
|
||||||
end
|
end
|
||||||
|
|
||||||
def include_topic_url?
|
def include_topic_url?
|
||||||
|
|
|
@ -249,7 +249,7 @@ class PostAlerter
|
||||||
end
|
end
|
||||||
|
|
||||||
def should_notify_edit?(notification, opts)
|
def should_notify_edit?(notification, opts)
|
||||||
return notification.data_hash["display_username"] != opts[:display_username]
|
notification.data_hash["display_username"] != opts[:display_username]
|
||||||
end
|
end
|
||||||
|
|
||||||
def should_notify_like?(user, notification)
|
def should_notify_like?(user, notification)
|
||||||
|
|
|
@ -36,6 +36,6 @@ class SiteSettingsTask
|
||||||
counts[:not_found] += 1
|
counts[:not_found] += 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return log, counts
|
[log, counts]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,7 +25,7 @@ class ThemesInstallTask
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return log, counts
|
[log, counts]
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :url, :options
|
attr_reader :url, :options
|
||||||
|
|
|
@ -38,7 +38,7 @@ class Auth::GithubAuthenticator < Auth::Authenticator
|
||||||
|
|
||||||
def valid?()
|
def valid?()
|
||||||
@validator.validate_each(self, :email, @email)
|
@validator.validate_each(self, :email, @email)
|
||||||
return errors.blank?
|
errors.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -437,7 +437,7 @@ class CookedPostProcessor
|
||||||
def get_filename(upload, src)
|
def get_filename(upload, src)
|
||||||
return File.basename(src) unless upload
|
return File.basename(src) unless upload
|
||||||
return upload.original_filename unless upload.original_filename =~ /^blob(\.png)?$/i
|
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
|
end
|
||||||
|
|
||||||
def create_node(tag_name, klass)
|
def create_node(tag_name, klass)
|
||||||
|
|
|
@ -370,7 +370,7 @@ module DiscourseTagging
|
||||||
tag_names.uniq!
|
tag_names.uniq!
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
def self.add_or_create_tags_by_name(taggable, tag_names_arg, opts = {})
|
def self.add_or_create_tags_by_name(taggable, tag_names_arg, opts = {})
|
||||||
|
|
|
@ -55,7 +55,7 @@ module FileStore
|
||||||
path, etag = @s3_helper.upload(file, path, options)
|
path, etag = @s3_helper.upload(file, path, options)
|
||||||
|
|
||||||
# return the upload url and etag
|
# return the upload url and etag
|
||||||
return File.join(absolute_base_url, path), etag
|
[File.join(absolute_base_url, path), etag]
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_file(url, path)
|
def remove_file(url, path)
|
||||||
|
|
|
@ -14,7 +14,7 @@ module ActiveRecord
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
# this is for Rails 5
|
# this is for Rails 5
|
||||||
def enforce_raw_sql_whitelist(*args)
|
def enforce_raw_sql_whitelist(*args)
|
||||||
return
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
BLANK_ARRAY = [].freeze
|
BLANK_ARRAY = [].freeze
|
||||||
|
@ -23,7 +23,7 @@ module ActiveRecord
|
||||||
def disallow_raw_sql!(args, permit: nil)
|
def disallow_raw_sql!(args, permit: nil)
|
||||||
# we may consider moving to https://github.com/rails/rails/pull/33330
|
# we may consider moving to https://github.com/rails/rails/pull/33330
|
||||||
# once all frozen string hints are in place
|
# once all frozen string hints are in place
|
||||||
return BLANK_ARRAY
|
BLANK_ARRAY
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -120,7 +120,7 @@ class Guardian
|
||||||
def can_see?(obj)
|
def can_see?(obj)
|
||||||
if obj
|
if obj
|
||||||
see_method = method_name_for :see, 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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -539,7 +539,7 @@ class Guardian
|
||||||
def can_do?(action, obj)
|
def can_do?(action, obj)
|
||||||
if obj && authenticated?
|
if obj && authenticated?
|
||||||
action_method = method_name_for action, obj
|
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
|
else
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,7 +27,7 @@ class IntroductionUpdater
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def summary_from_post(post)
|
def summary_from_post(post)
|
||||||
return post ? post.raw.split("\n").first : nil
|
post ? post.raw.split("\n").first : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_welcome_post
|
def find_welcome_post
|
||||||
|
|
|
@ -103,7 +103,7 @@ class Promotion
|
||||||
return false if (stat.time_read / 60) < SiteSetting.tl1_requires_time_spent_mins
|
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 false if ((Time.now - user.created_at) / 60) < SiteSetting.tl1_requires_time_spent_mins
|
||||||
|
|
||||||
return true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.tl3_met?(user)
|
def self.tl3_met?(user)
|
||||||
|
|
|
@ -67,6 +67,6 @@ module RetrieveTitle
|
||||||
title = extract_title(current)
|
title = extract_title(current)
|
||||||
throw :done if title || max_size < current.length
|
throw :done if title || max_size < current.length
|
||||||
end
|
end
|
||||||
return title
|
title
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,7 +47,7 @@ class S3Helper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return path, etag.gsub('"', '')
|
[path, etag.gsub('"', '')]
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove(s3_filename, copy_to_tombstone = false)
|
def remove(s3_filename, copy_to_tombstone = false)
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Unread
|
||||||
|
|
||||||
new_posts = (highest_post_number - @topic_user.highest_seen_post_number)
|
new_posts = (highest_post_number - @topic_user.highest_seen_post_number)
|
||||||
new_posts = 0 if new_posts < 0
|
new_posts = 0 if new_posts < 0
|
||||||
return new_posts
|
new_posts
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
|
@ -778,7 +778,7 @@ class BulkImport::Base
|
||||||
|
|
||||||
def normalize_charset(text)
|
def normalize_charset(text)
|
||||||
return text if @encoding == Encoding::UTF_8
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -882,7 +882,7 @@ class ImportScripts::DiscuzX < ImportScripts::Base
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
return upload, real_filename
|
[upload, real_filename]
|
||||||
end
|
end
|
||||||
|
|
||||||
# find the uploaded file and real name from the db
|
# find the uploaded file and real name from the db
|
||||||
|
@ -938,12 +938,12 @@ class ImportScripts::DiscuzX < ImportScripts::Base
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
return upload, real_filename
|
[upload, real_filename]
|
||||||
rescue Mysql2::Error => e
|
rescue Mysql2::Error => e
|
||||||
puts "SQL Error"
|
puts "SQL Error"
|
||||||
puts e.message
|
puts e.message
|
||||||
puts sql
|
puts sql
|
||||||
return nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def first_exists(*items)
|
def first_exists(*items)
|
||||||
|
|
|
@ -196,7 +196,7 @@ class DisqusSAX < Nokogiri::XML::SAX::Document
|
||||||
end
|
end
|
||||||
|
|
||||||
def inside?(*params)
|
def inside?(*params)
|
||||||
return !params.find { |p| !@inside[p] }
|
!params.find { |p| !@inside[p] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize
|
def normalize
|
||||||
|
|
|
@ -457,7 +457,7 @@ class ImportScripts::FMGP < ImportScripts::Base
|
||||||
end
|
end
|
||||||
# FIXME: import G+ "+1" as "like" if F+MG+E feature request implemented
|
# FIXME: import G+ "+1" as "like" if F+MG+E feature request implemented
|
||||||
|
|
||||||
return mapped
|
mapped
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_title(post, created_at)
|
def parse_title(post, created_at)
|
||||||
|
@ -524,7 +524,7 @@ class ImportScripts::FMGP < ImportScripts::Base
|
||||||
words << fragment[1]
|
words << fragment[1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return words
|
words
|
||||||
end
|
end
|
||||||
|
|
||||||
def formatted_message(post)
|
def formatted_message(post)
|
||||||
|
@ -588,10 +588,10 @@ class ImportScripts::FMGP < ImportScripts::Base
|
||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
elsif fragment[0] == 1
|
elsif fragment[0] == 1
|
||||||
return "\n"
|
"\n"
|
||||||
elsif fragment[0] == 2
|
elsif fragment[0] == 2
|
||||||
urls_seen.add(fragment[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
|
elsif fragment[0] == 3
|
||||||
# reference to a user
|
# reference to a user
|
||||||
if @usermap.include?(fragment[2].to_s)
|
if @usermap.include?(fragment[2].to_s)
|
||||||
|
@ -619,7 +619,7 @@ class ImportScripts::FMGP < ImportScripts::Base
|
||||||
end
|
end
|
||||||
elsif fragment[0] == 4
|
elsif fragment[0] == 4
|
||||||
# hashtag, the octothorpe is included
|
# hashtag, the octothorpe is included
|
||||||
return fragment[1]
|
fragment[1]
|
||||||
else
|
else
|
||||||
raise RuntimeError.new("message code #{fragment[0]} not recognized!")
|
raise RuntimeError.new("message code #{fragment[0]} not recognized!")
|
||||||
end
|
end
|
||||||
|
|
|
@ -855,7 +855,7 @@ SQL
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
return upload, real_filename
|
[upload, real_filename]
|
||||||
end
|
end
|
||||||
|
|
||||||
def post_process_posts
|
def post_process_posts
|
||||||
|
|
|
@ -181,7 +181,7 @@ class ImportScripts::MyBB < ImportScripts::Base
|
||||||
if count > 5
|
if count > 5
|
||||||
puts "Warning: probably incorrect quote in post #{post_id}"
|
puts "Warning: probably incorrect quote in post #{post_id}"
|
||||||
end
|
end
|
||||||
return username
|
username
|
||||||
end
|
end
|
||||||
|
|
||||||
# Take an original post id and return the migrated topic id and post number for it
|
# Take an original post id and return the migrated topic id and post number for it
|
||||||
|
|
|
@ -244,7 +244,7 @@ class ImportScripts::Smf2 < ImportScripts::Base
|
||||||
raise "Attachment for post #{post[:id]} failed: #{attachment[:filename]}" unless path.present?
|
raise "Attachment for post #{post[:id]} failed: #{attachment[:filename]}" unless path.present?
|
||||||
upload = create_upload(post[:user_id], path, attachment[:filename])
|
upload = create_upload(post[:user_id], path, attachment[:filename])
|
||||||
raise "Attachment for post #{post[:id]} failed: #{upload.errors.full_messages.join(', ')}" unless upload.persisted?
|
raise "Attachment for post #{post[:id]} failed: #{upload.errors.full_messages.join(', ')}" unless upload.persisted?
|
||||||
return upload
|
upload
|
||||||
rescue SystemCallError => err
|
rescue SystemCallError => err
|
||||||
raise "Attachment for post #{post[:id]} failed: #{err.message}"
|
raise "Attachment for post #{post[:id]} failed: #{err.message}"
|
||||||
end
|
end
|
||||||
|
@ -280,7 +280,7 @@ class ImportScripts::Smf2 < ImportScripts::Base
|
||||||
return __query(db, sql).to_a if opts[:as] == :array
|
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, 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).each(&block) if block_given?
|
||||||
return __query(db, sql, stream: true)
|
__query(db, sql, stream: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def __query(db, sql, **opts)
|
def __query(db, sql, **opts)
|
||||||
|
@ -345,7 +345,7 @@ class ImportScripts::Smf2 < ImportScripts::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return opts[:ignore_quotes] ? body : convert_quotes(body)
|
opts[:ignore_quotes] ? body : convert_quotes(body)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_upload_markdown(upload)
|
def get_upload_markdown(upload)
|
||||||
|
|
|
@ -359,12 +359,12 @@ class ImportScripts::VBulletin < ImportScripts::Base
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
return upload, real_filename
|
[upload, real_filename]
|
||||||
rescue Mysql2::Error => e
|
rescue Mysql2::Error => e
|
||||||
puts "SQL Error"
|
puts "SQL Error"
|
||||||
puts e.message
|
puts e.message
|
||||||
puts sql
|
puts sql
|
||||||
return nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_attachments
|
def import_attachments
|
||||||
|
|
|
@ -85,7 +85,7 @@ def consume_mapping(map_lines, totals)
|
||||||
Mapping::FIELDS.each do |field|
|
Mapping::FIELDS.each do |field|
|
||||||
totals[field] += m.public_send(field)
|
totals[field] += m.public_send(field)
|
||||||
end
|
end
|
||||||
return m
|
m
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_memstats_not_available(totals)
|
def create_memstats_not_available(totals)
|
||||||
|
@ -136,7 +136,7 @@ def get_commandline(pid)
|
||||||
loop { break if commandline.shift == "-jar" }
|
loop { break if commandline.shift == "-jar" }
|
||||||
return "[java] #{commandline.shift}"
|
return "[java] #{commandline.shift}"
|
||||||
end
|
end
|
||||||
return commandline.join(' ')
|
commandline.join(' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
if ARGV.include? '--yaml'
|
if ARGV.include? '--yaml'
|
||||||
|
|
|
@ -267,7 +267,7 @@ HTML
|
||||||
def transpile(html)
|
def transpile(html)
|
||||||
f = ThemeField.create!(target_id: Theme.targets[:mobile], theme_id: 1, name: "after_header", value: html)
|
f = ThemeField.create!(target_id: Theme.targets[:mobile], theme_id: 1, name: "after_header", value: html)
|
||||||
f.ensure_baked!
|
f.ensure_baked!
|
||||||
return f.value_baked, f.javascript_cache
|
[f.value_baked, f.javascript_cache]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "transpiles ES6 code" do
|
it "transpiles ES6 code" do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user