Fix various rubocop issues.
This commit is contained in:
@@ -121,7 +121,7 @@ module ApplicationHelper
|
|||||||
link_to text, wiki_page_path(title), class: "wiki-link", **options
|
link_to text, wiki_page_path(title), class: "wiki-link", **options
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_to_wikis(*wiki_titles, last_word_connector: ", or", **options)
|
def link_to_wikis(*wiki_titles, **options)
|
||||||
links = wiki_titles.map do |title|
|
links = wiki_titles.map do |title|
|
||||||
link_to_wiki title.tr("_", " "), title
|
link_to_wiki title.tr("_", " "), title
|
||||||
end
|
end
|
||||||
@@ -245,7 +245,7 @@ module ApplicationHelper
|
|||||||
|
|
||||||
def data_attributes_for(record, prefix, attributes)
|
def data_attributes_for(record, prefix, attributes)
|
||||||
attributes.map do |attr|
|
attributes.map do |attr|
|
||||||
if attr.kind_of?(Array)
|
if attr.is_a?(Array)
|
||||||
name = attr.map {|sym| sym.to_s.dasherize.delete("?")}.join('-')
|
name = attr.map {|sym| sym.to_s.dasherize.delete("?")}.join('-')
|
||||||
value = record
|
value = record
|
||||||
attr.each do |sym|
|
attr.each do |sym|
|
||||||
@@ -261,7 +261,7 @@ module ApplicationHelper
|
|||||||
if value.nil?
|
if value.nil?
|
||||||
value = "null"
|
value = "null"
|
||||||
end
|
end
|
||||||
if prefix.length == 0
|
if prefix.blank?
|
||||||
[:"#{name}", value]
|
[:"#{name}", value]
|
||||||
else
|
else
|
||||||
[:"#{prefix}-#{name}", value]
|
[:"#{prefix}-#{name}", value]
|
||||||
|
|||||||
@@ -2,5 +2,4 @@ module ArtistCommentaryVersionsHelper
|
|||||||
def artist_commentary_versions_listing_type
|
def artist_commentary_versions_listing_type
|
||||||
params.dig(:search, :post_id).present? ? :revert : :standard
|
params.dig(:search, :post_id).present? ? :revert : :standard
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module NoteVersionsHelper
|
module NoteVersionsHelper
|
||||||
def note_versions_listing_type
|
def note_versions_listing_type
|
||||||
(params.dig(:search, :post_id).present? || params.dig(:search, :note_id).present?) && CurrentUser.is_member? ? :revert : :standard
|
((params.dig(:search, :post_id).present? || params.dig(:search, :note_id).present?) && CurrentUser.is_member?) ? :revert : :standard
|
||||||
end
|
end
|
||||||
|
|
||||||
def note_version_body_diff_info(note_version)
|
def note_version_body_diff_info(note_version)
|
||||||
|
|||||||
@@ -23,4 +23,4 @@ module PoolVersionsHelper
|
|||||||
pattern = Regexp.new('(?:<.+?>)|(?:\w+)|(?:[ \t]+)|(?:\r?\n)|(?:.+?)')
|
pattern = Regexp.new('(?:<.+?>)|(?:\w+)|(?:[ \t]+)|(?:\r?\n)|(?:.+?)')
|
||||||
DiffBuilder.new(other_version.description, pool_version.description, pattern).build
|
DiffBuilder.new(other_version.description, pool_version.description, pattern).build
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module Danbooru
|
module Danbooru
|
||||||
class Http
|
class Http
|
||||||
attr_accessor :cache, :http
|
attr_writer :cache, :http
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
delegate :get, :post, :delete, :cache, :auth, :basic_auth, :headers, to: :new
|
delegate :get, :post, :delete, :cache, :auth, :basic_auth, :headers, to: :new
|
||||||
|
|||||||
@@ -40,9 +40,7 @@ class PostQueryBuilder
|
|||||||
end
|
end
|
||||||
|
|
||||||
def escape_string_for_tsquery(array)
|
def escape_string_for_tsquery(array)
|
||||||
array.map do |token|
|
array.map(&:to_escaped_for_tsquery)
|
||||||
token.to_escaped_for_tsquery
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_tag_string_search_relation(tags, relation)
|
def add_tag_string_search_relation(tags, relation)
|
||||||
@@ -314,7 +312,7 @@ class PostQueryBuilder
|
|||||||
elsif flagger_id == "none"
|
elsif flagger_id == "none"
|
||||||
relation = relation.where('NOT EXISTS (' + PostFlag.unscoped.search(:category => "normal").where('post_id = posts.id').reorder('').select('1').to_sql + ')')
|
relation = relation.where('NOT EXISTS (' + PostFlag.unscoped.search(:category => "normal").where('post_id = posts.id').reorder('').select('1').to_sql + ')')
|
||||||
elsif CurrentUser.can_view_flagger?(flagger_id)
|
elsif CurrentUser.can_view_flagger?(flagger_id)
|
||||||
post_ids = PostFlag.unscoped.search(:creator_id => flagger_id, :category => "normal").reorder("").select {|flag| flag.not_uploaded_by?(CurrentUser.id)}.map {|flag| flag.post_id}.uniq
|
post_ids = PostFlag.unscoped.search(creator_id: flagger_id, category: "normal").reorder("").select {|flag| flag.not_uploaded_by?(CurrentUser.id)}.map(&:post_id).uniq
|
||||||
relation = relation.where("posts.id": post_ids)
|
relation = relation.where("posts.id": post_ids)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -78,11 +78,11 @@ module PostSets
|
|||||||
end
|
end
|
||||||
|
|
||||||
def hidden_posts
|
def hidden_posts
|
||||||
posts.reject { |p| p.visible? }
|
posts.reject(&:visible?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def banned_posts
|
def banned_posts
|
||||||
posts.select { |p| p.banblocked? }
|
posts.select(&:banblocked?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def censored_posts
|
def censored_posts
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ class PostVoteSimilarity
|
|||||||
@score = score
|
@score = score
|
||||||
end
|
end
|
||||||
|
|
||||||
def <=>(rhs)
|
def <=>(other)
|
||||||
score <=> rhs.score
|
score <=> other.score
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -240,11 +240,6 @@ module Sources
|
|||||||
self.class.to_dtext(artist_commentary_desc)
|
self.class.to_dtext(artist_commentary_desc)
|
||||||
end
|
end
|
||||||
|
|
||||||
# A strategy may return extra data unrelated to the file
|
|
||||||
def data
|
|
||||||
return {}
|
|
||||||
end
|
|
||||||
|
|
||||||
# A search query that should return any posts that were previously
|
# A search query that should return any posts that were previously
|
||||||
# uploaded from the same source. These may be duplicates, or they may be
|
# uploaded from the same source. These may be duplicates, or they may be
|
||||||
# other posts from the same gallery.
|
# other posts from the same gallery.
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ module Sources::Strategies
|
|||||||
|
|
||||||
def normalize_tag(tag)
|
def normalize_tag(tag)
|
||||||
COMMON_TAG_REGEXES.each do |rg|
|
COMMON_TAG_REGEXES.each do |rg|
|
||||||
norm_tag = tag.gsub(rg,"")
|
norm_tag = tag.gsub(rg, "")
|
||||||
if norm_tag != tag
|
if norm_tag != tag
|
||||||
return norm_tag
|
return norm_tag
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class TableBuilder
|
|||||||
@block = block
|
@block = block
|
||||||
|
|
||||||
@name = name || attribute
|
@name = name || attribute
|
||||||
@name = @name.to_s.titleize unless @name.kind_of?(String)
|
@name = @name.to_s.titleize unless @name.is_a?(String)
|
||||||
|
|
||||||
if @name.present?
|
if @name.present?
|
||||||
column_class = "#{@name.parameterize.dasherize}-column"
|
column_class = "#{@name.parameterize.dasherize}-column"
|
||||||
@@ -22,7 +22,7 @@ class TableBuilder
|
|||||||
if block.present?
|
if block.present?
|
||||||
block.call(item, i, j, self)
|
block.call(item, i, j, self)
|
||||||
nil
|
nil
|
||||||
elsif attribute.kind_of?(Symbol)
|
elsif attribute.is_a?(Symbol)
|
||||||
item.send(attribute)
|
item.send(attribute)
|
||||||
else
|
else
|
||||||
""
|
""
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
module TagRelationshipRetirementService
|
module TagRelationshipRetirementService
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
THRESHOLD = 2.years
|
THRESHOLD = 2.years
|
||||||
|
|
||||||
def forum_topic_title
|
def forum_topic_title
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
class UploadService
|
class UploadService
|
||||||
module Utils
|
module Utils
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
class CorruptFileError < RuntimeError; end
|
class CorruptFileError < RuntimeError; end
|
||||||
|
|
||||||
def file_header_to_file_ext(file)
|
def file_header_to_file_ext(file)
|
||||||
|
|||||||
@@ -371,7 +371,7 @@ class Artist < ApplicationRecord
|
|||||||
elsif wiki_page.nil?
|
elsif wiki_page.nil?
|
||||||
# if there are any notes, we need to create a new wiki page
|
# if there are any notes, we need to create a new wiki page
|
||||||
if @notes.present?
|
if @notes.present?
|
||||||
wp = create_wiki_page(body: @notes, title: name)
|
create_wiki_page(body: @notes, title: name)
|
||||||
end
|
end
|
||||||
elsif (!@notes.nil? && (wiki_page.body != @notes)) || wiki_page.title != name
|
elsif (!@notes.nil? && (wiki_page.body != @notes)) || wiki_page.title != name
|
||||||
# if anything changed, we need to update the wiki page
|
# if anything changed, we need to update the wiki page
|
||||||
@@ -402,10 +402,10 @@ class Artist < ApplicationRecord
|
|||||||
def unban!
|
def unban!
|
||||||
Post.transaction do
|
Post.transaction do
|
||||||
CurrentUser.without_safe_mode do
|
CurrentUser.without_safe_mode do
|
||||||
ti = TagImplication.where(:antecedent_name => name, :consequent_name => "banned_artist").first
|
ti = TagImplication.find_by(antecedent_name: name, consequent_name: "banned_artist")
|
||||||
ti&.destroy
|
ti&.destroy
|
||||||
|
|
||||||
Post.tag_match(name).where("true /* Artist.unban */").each do |post|
|
Post.tag_match(name).find_each do |post|
|
||||||
post.unban!
|
post.unban!
|
||||||
fixed_tags = post.tag_string.sub(/(?:\A| )banned_artist(?:\Z| )/, " ").strip
|
fixed_tags = post.tag_string.sub(/(?:\A| )banned_artist(?:\Z| )/, " ").strip
|
||||||
post.update(tag_string: fixed_tags)
|
post.update(tag_string: fixed_tags)
|
||||||
@@ -420,9 +420,7 @@ class Artist < ApplicationRecord
|
|||||||
def ban!
|
def ban!
|
||||||
Post.transaction do
|
Post.transaction do
|
||||||
CurrentUser.without_safe_mode do
|
CurrentUser.without_safe_mode do
|
||||||
Post.tag_match(name).where("true /* Artist.ban */").each do |post|
|
Post.tag_match(name).each(&:ban!)
|
||||||
post.ban!
|
|
||||||
end
|
|
||||||
|
|
||||||
# potential race condition but unlikely
|
# potential race condition but unlikely
|
||||||
unless TagImplication.where(:antecedent_name => name, :consequent_name => "banned_artist").exists?
|
unless TagImplication.where(:antecedent_name => name, :consequent_name => "banned_artist").exists?
|
||||||
|
|||||||
@@ -636,7 +636,7 @@ class Post < ApplicationRecord
|
|||||||
def normalize_tags
|
def normalize_tags
|
||||||
normalized_tags = Tag.scan_tags(tag_string)
|
normalized_tags = Tag.scan_tags(tag_string)
|
||||||
normalized_tags = apply_casesensitive_metatags(normalized_tags)
|
normalized_tags = apply_casesensitive_metatags(normalized_tags)
|
||||||
normalized_tags = normalized_tags.map {|tag| tag.downcase}
|
normalized_tags = normalized_tags.map(&:downcase)
|
||||||
normalized_tags = filter_metatags(normalized_tags)
|
normalized_tags = filter_metatags(normalized_tags)
|
||||||
normalized_tags = remove_negated_tags(normalized_tags)
|
normalized_tags = remove_negated_tags(normalized_tags)
|
||||||
normalized_tags = TagAlias.to_aliased(normalized_tags)
|
normalized_tags = TagAlias.to_aliased(normalized_tags)
|
||||||
@@ -1256,7 +1256,7 @@ class Post < ApplicationRecord
|
|||||||
|
|
||||||
def children_ids
|
def children_ids
|
||||||
if has_children?
|
if has_children?
|
||||||
children.map {|p| p.id}.join(' ')
|
children.map(&:id).join(' ')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1335,7 +1335,7 @@ class Post < ApplicationRecord
|
|||||||
|
|
||||||
self.is_deleted = false
|
self.is_deleted = false
|
||||||
self.approver_id = CurrentUser.id
|
self.approver_id = CurrentUser.id
|
||||||
flags.each {|x| x.resolve!}
|
flags.each(&:resolve!)
|
||||||
save
|
save
|
||||||
ModAction.log("undeleted post ##{id}", :post_undelete)
|
ModAction.log("undeleted post ##{id}", :post_undelete)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user