DEV: Correct `Style/RedundantReturn` rubocop issues (#23052)

This commit is contained in:
Jarek Radosz 2023-08-10 02:03:38 +02:00 committed by GitHub
parent 7954d34448
commit 94649565ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 24 additions and 19 deletions

View File

@ -980,15 +980,19 @@ class Group < ActiveRecord::Base
end end
def flair_type def flair_type
return :icon if flair_icon.present? if flair_icon.present?
return :image if flair_upload.present? :icon
elsif flair_upload.present?
:image
end
end end
def flair_url def flair_url
return flair_icon if flair_type == :icon if flair_type == :icon
return upload_cdn_path(flair_upload.url) if flair_type == :image flair_icon
elsif flair_type == :image
nil upload_cdn_path(flair_upload.url)
end
end end
%i[muted regular tracking watching watching_first_post].each do |level| %i[muted regular tracking watching watching_first_post].each do |level|

View File

@ -1251,7 +1251,7 @@ class User < ActiveRecord::Base
end end
def full_suspend_reason def full_suspend_reason
return suspend_record.try(:details) if suspended? suspend_record.try(:details) if suspended?
end end
def suspend_reason def suspend_reason

View File

@ -363,11 +363,11 @@ module ExternalUploadHelpers
end end
def external_store_check def external_store_check
return render_404 if !Discourse.store.external? render_404 if !Discourse.store.external?
end end
def direct_s3_uploads_check def direct_s3_uploads_check
return render_404 if !SiteSetting.enable_direct_s3_uploads render_404 if !SiteSetting.enable_direct_s3_uploads
end end
def can_upload_external? def can_upload_external?

View File

@ -646,7 +646,7 @@ class Guardian
def method_name_for(action, obj) def method_name_for(action, obj)
method_name = :"can_#{action}_#{obj.class.name.underscore}?" method_name = :"can_#{action}_#{obj.class.name.underscore}?"
return method_name if respond_to?(method_name) method_name if respond_to?(method_name)
end end
def can_do?(action, obj) def can_do?(action, obj)

View File

@ -191,7 +191,8 @@ module Onebox
return image_html if is_image? return image_html if is_image?
return embedded_html if is_embedded? return embedded_html if is_embedded?
return card_html if is_card? return card_html if is_card?
return article_html if (has_text? || is_image_article?)
article_html if (has_text? || is_image_article?)
end end
def is_card? def is_card?

View File

@ -41,7 +41,7 @@ module PrettyText
return erb_name if File.file?("#{root}#{erb_name}") return erb_name if File.file?("#{root}#{erb_name}")
erb_name = "#{filename}.js.erb" erb_name = "#{filename}.js.erb"
return erb_name if File.file?("#{root}#{erb_name}") erb_name if File.file?("#{root}#{erb_name}")
end end
def self.apply_es6_file(ctx, root_path, part_name) def self.apply_es6_file(ctx, root_path, part_name)

View File

@ -16,7 +16,7 @@ class QuoteComparer
# philosophy of "catch the obvious cases, leave moderation for the # philosophy of "catch the obvious cases, leave moderation for the
# complicated ones" # complicated ones"
def missing? def missing?
return true if @parent_post.blank? @parent_post.blank?
end end
def modified? def modified?

View File

@ -138,7 +138,7 @@ class Typepad < Thor
type = clean_type!(Regexp.last_match[1]) type = clean_type!(Regexp.last_match[1])
value = section.split("\n")[1..-1].join("\n") value = section.split("\n")[1..-1].join("\n")
value.strip! value.strip!
return [type.to_sym, value] if value.present? [type.to_sym, value] if value.present?
end end
end end

View File

@ -17,7 +17,7 @@ class CreateTitle
title = complete_words title title = complete_words title
end end
return title unless title.nil? || title.size < 20 title unless title.nil? || title.size < 20
end end
private private

View File

@ -18,12 +18,12 @@ RSpec.describe QuoteComparer do
expect(QuoteComparer.new(post.topic_id, nil, "test")).to be_missing expect(QuoteComparer.new(post.topic_id, nil, "test")).to be_missing
end end
it "returns a falsey value for only missing text" do it "returns false for only missing text" do
expect(QuoteComparer.new(post.topic_id, post.post_number, nil).missing?).to be(nil) expect(QuoteComparer.new(post.topic_id, post.post_number, nil)).to_not be_missing
end end
it "returns a falsey value for no missing topic and post" do it "returns false for no missing topic and post" do
expect(QuoteComparer.new(post.topic_id, post.post_number, "test").missing?).to be(nil) expect(QuoteComparer.new(post.topic_id, post.post_number, "test")).to_not be_missing
end end
end end