rubocop: fix various style issues.

This commit is contained in:
evazion
2019-12-22 16:21:58 -06:00
parent 09f6a84660
commit 309821bf73
288 changed files with 912 additions and 962 deletions

View File

@@ -173,12 +173,12 @@ class PostPresenter < Presenter
end
def has_nav_links?(template)
has_sequential_navigation?(template.params) || @post.pools.undeleted.any? || @post.favorite_groups(active_id=template.params[:favgroup_id]).any?
has_sequential_navigation?(template.params) || @post.pools.undeleted.any? || @post.favorite_groups(active_id = template.params[:favgroup_id]).any?
end
def has_sequential_navigation?(params)
return false if Tag.has_metatag?(params[:q], :order, :ordfav, :ordpool)
return false if params[:pool_id].present? || params[:favgroup_id].present?
return CurrentUser.user.enable_sequential_post_navigation
return CurrentUser.user.enable_sequential_post_navigation
end
end

View File

@@ -4,7 +4,7 @@ class Presenter
end
def self.u(s)
URI.escape(s)
CGI.escape(s)
end
def h(s)

View File

@@ -1,8 +1,7 @@
=begin rdoc
A tag set represents a set of tags that are displayed together.
This class makes it easy to fetch the categories for all the
tags in one call instead of fetching them sequentially.
=end
# rdoc
# A tag set represents a set of tags that are displayed together.
# This class makes it easy to fetch the categories for all the
# tags in one call instead of fetching them sequentially.
class TagSetPresenter < Presenter
extend Memoist
@@ -77,7 +76,7 @@ class TagSetPresenter < Presenter
artists = "drawn by #{artists}" if artists.present?
strings = "#{characters} #{copyrights} #{artists}"
strings.blank? ? default : strings
strings.presence || default
end
private
@@ -133,7 +132,7 @@ class TagSetPresenter < Presenter
if count >= 10_000
post_count = "#{count / 1_000}k"
elsif count >= 1_000
post_count = "%.1fk" % (count / 1_000.0)
post_count = format("%.1fk", (count / 1_000.0))
else
post_count = count
end

View File

@@ -51,9 +51,9 @@ class UserPresenter
slots_tooltip = "Next free slot: #{template.time_ago_in_words(user.next_free_upload_slot)}"
limit_tooltip = <<-EOS.strip_heredoc
Base: #{user.base_upload_limit}
Del. Rate: #{"%.2f" % user.adjusted_deletion_confidence}
Multiplier: (1 - (#{"%.2f" % user.adjusted_deletion_confidence} / 15)) = #{user.upload_limit_multiplier}
Upload Limit: #{user.base_upload_limit} * #{"%.2f" % user.upload_limit_multiplier} = #{user.max_upload_limit}
Del. Rate: #{format("%.2f", user.adjusted_deletion_confidence)}
Multiplier: (1 - (#{format("%.2f", user.adjusted_deletion_confidence)} / 15)) = #{user.upload_limit_multiplier}
Upload Limit: #{user.base_upload_limit} * #{format("%.2f", user.upload_limit_multiplier)} = #{user.max_upload_limit}
EOS
%{<abbr title="#{slots_tooltip}">#{user.used_upload_slots}</abbr> / <abbr title="#{limit_tooltip}">#{user.max_upload_limit}</abbr>}.html_safe
@@ -164,7 +164,7 @@ class UserPresenter
[]
end
end
def previous_names(template)
user.user_name_change_requests.map { |req| template.link_to req.original_name, req }.join(", ").html_safe
end

View File

@@ -19,15 +19,15 @@ class WikiPagePresenter
cbo = Diff::LCS::ContextDiffCallbacks.new
diffs = thisarr.diff(otharr, cbo)
escape_html = ->(str) {str.gsub(/&/,'&amp;').gsub(/</,'&lt;').gsub(/>/,'&gt;')}
escape_html = ->(str) {str.gsub(/&/, '&amp;').gsub(/</, '&lt;').gsub(/>/, '&gt;')}
output = thisarr;
output = thisarr
output.each { |q| q.replace(CGI.escape_html(q)) }
diffs.reverse_each do |hunk|
newchange = hunk.max{|a,b| a.old_position <=> b.old_position}
newchange = hunk.max {|a, b| a.old_position <=> b.old_position}
newstart = newchange.old_position
oldstart = hunk.min{|a,b| a.old_position <=> b.old_position}.old_position
oldstart = hunk.min {|a, b| a.old_position <=> b.old_position}.old_position
if newchange.action == '+'
output.insert(newstart, "</ins>")
@@ -42,7 +42,7 @@ class WikiPagePresenter
if chg.new_element.match(/^\r?\n$/)
output.insert(chg.old_position, "[nl]")
else
output.insert(chg.old_position, "#{escape_html[chg.new_element]}")
output.insert(chg.old_position, (escape_html[chg.new_element]).to_s)
end
end
end
@@ -52,7 +52,7 @@ class WikiPagePresenter
end
if hunk[0].action == '-'
output.insert((newstart == oldstart || newchange.action != '+') ? newstart+1 : newstart, "</del>")
output.insert((newstart == oldstart || newchange.action != '+') ? newstart + 1 : newstart, "</del>")
output.insert(oldstart, "<del>")
end
end