Autofix Rubocop Style/RedundantBegin (#23703)

This commit is contained in:
Nick Schonning
2023-02-18 17:09:40 -05:00
committed by GitHub
parent 167709f6b0
commit 2177daeae9
69 changed files with 458 additions and 695 deletions

View File

@ -113,13 +113,11 @@ class Trends::Links < Trends::Base
max_score = preview_card.max_score
max_score = 0 if max_time.nil? || max_time < (at_time - options[:max_score_cooldown])
score = begin
if expected > observed || observed < options[:threshold]
0
else
((observed - expected)**2) / expected
end
end
score = if expected > observed || observed < options[:threshold]
0
else
((observed - expected)**2) / expected
end
if score > max_score
max_score = score
@ -129,13 +127,11 @@ class Trends::Links < Trends::Base
preview_card.update_columns(max_score: max_score, max_score_at: max_time)
end
decaying_score = begin
if max_score.zero? || !valid_locale?(preview_card.language)
0
else
max_score * (0.5**((at_time.to_f - max_time.to_f) / options[:max_score_halflife].to_f))
end
end
decaying_score = if max_score.zero? || !valid_locale?(preview_card.language)
0
else
max_score * (0.5**((at_time.to_f - max_time.to_f) / options[:max_score_halflife].to_f))
end
[decaying_score, preview_card]
end

View File

@ -99,21 +99,17 @@ class Trends::Statuses < Trends::Base
expected = 1.0
observed = (status.reblogs_count + status.favourites_count).to_f
score = begin
if expected > observed || observed < options[:threshold]
0
else
((observed - expected)**2) / expected
end
end
score = if expected > observed || observed < options[:threshold]
0
else
((observed - expected)**2) / expected
end
decaying_score = begin
if score.zero? || !eligible?(status)
0
else
score * (0.5**((at_time.to_f - status.created_at.to_f) / options[:score_halflife].to_f))
end
end
decaying_score = if score.zero? || !eligible?(status)
0
else
score * (0.5**((at_time.to_f - status.created_at.to_f) / options[:score_halflife].to_f))
end
[decaying_score, status]
end

View File

@ -13,13 +13,11 @@ class Trends::TagFilter
end
def results
scope = begin
if params[:status] == 'pending_review'
Tag.unscoped
else
trending_scope
end
end
scope = if params[:status] == 'pending_review'
Tag.unscoped
else
trending_scope
end
params.each do |key, value|
next if key.to_s == 'page'

View File

@ -63,13 +63,11 @@ class Trends::Tags < Trends::Base
max_score = tag.max_score
max_score = 0 if max_time.nil? || max_time < (at_time - options[:max_score_cooldown])
score = begin
if expected > observed || observed < options[:threshold]
0
else
((observed - expected)**2) / expected
end
end
score = if expected > observed || observed < options[:threshold]
0
else
((observed - expected)**2) / expected
end
if score > max_score
max_score = score