[Gems] Bump rubocop

This commit is contained in:
Earlopain 2023-12-03 15:36:37 +01:00
parent 3fe3c85cb6
commit 6bb4c272cc
No known key found for this signature in database
GPG Key ID: 48860312319ADF61
23 changed files with 38 additions and 36 deletions

View File

@ -206,7 +206,7 @@ GEM
faraday (>= 1.0, < 3)
multi_json (>= 1.0)
parallel (1.23.0)
parser (3.2.2.3)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
pg (1.5.3)
@ -259,7 +259,7 @@ GEM
redis-client (>= 0.9.0)
redis-client (0.15.0)
connection_pool
regexp_parser (2.8.1)
regexp_parser (2.8.2)
request_store (1.5.1)
rack (>= 1.4)
resolv (0.2.2)
@ -275,26 +275,27 @@ GEM
reverse_markdown (2.1.1)
nokogiri
rexml (3.2.6)
rubocop (1.55.1)
rubocop (1.58.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
parser (>= 3.2.2.4)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-erb (0.3.0)
better_html
rubocop (~> 1.45)
rubocop-rails (2.20.2)
rubocop-rails (2.22.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (1.13.0)
ruby-vips (2.1.4)
ffi (~> 1.12)
@ -344,7 +345,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
unicode-display_width (2.4.2)
unicode-display_width (2.5.0)
unicorn (6.1.0)
kgio (~> 2.6)
raindrops (~> 0.7)

View File

@ -21,7 +21,7 @@ module Admin
moved_post_ids << p.id
p.do_not_version_changes = true
p.update({ uploader_id: @new_user.id })
p.versions.where(updater_id: @old_user.id).each do |pv|
p.versions.where(updater_id: @old_user.id).find_each do |pv|
pv.update_column(:updater_id, @new_user.id)
pv.update_index
end

View File

@ -45,7 +45,7 @@ class CommentsController < ApplicationController
flash[:notice] = @comment.valid? ? "Comment posted" : @comment.errors.full_messages.join("; ")
respond_with(@comment) do |format|
format.html do
redirect_back fallback_location: (@comment.post || comments_path)
redirect_back fallback_location: @comment.post || comments_path
end
end
end

View File

@ -109,7 +109,7 @@ class UsersController < ApplicationController
private
def check_privilege(user)
raise User::PrivilegeError unless (user.id == CurrentUser.id || CurrentUser.is_admin?)
raise User::PrivilegeError unless user.id == CurrentUser.id || CurrentUser.is_admin?
raise User::PrivilegeError.new("Must verify account email") unless CurrentUser.is_verified?
end

View File

@ -2,5 +2,6 @@ module TitleHelper
def get_title
return Danbooru.config.app_name if current_page? root_path
return content_for(:page_title) + " - " + Danbooru.config.app_name if content_for? :page_title
""
end
end

View File

@ -268,7 +268,7 @@ class ElasticPostQueryBuilder < ElasticQueryBuilder
when "filesize_asc"
order.push({file_size: :asc})
when /\A(?<column>#{TagQuery::COUNT_METATAGS.join("|")})(_(?<direction>asc|desc))?\z/i
when /\A(?<column>#{TagQuery::COUNT_METATAGS.join('|')})(_(?<direction>asc|desc))?\z/i
column = Regexp.last_match[:column]
direction = Regexp.last_match[:direction] || "desc"
order.concat([{column => direction}, {id: direction}])

View File

@ -113,7 +113,7 @@ module ParseValue
when :ratio
left, right = object.split(":", 2)
if right && right.to_f != 0.0 # rubocop:disable Lint/FloatComparison
if right && right.to_f != 0.0
(left.to_f / right.to_f).round(2)
elsif right
0.0

View File

@ -11,7 +11,7 @@ class PostPruner
def prune_pending!
CurrentUser.as_system do
Post.where("is_deleted = ? and is_pending = ? and created_at < ?", false, true, DELETION_WINDOW.days.ago).each do |post|
Post.where("is_deleted = ? and is_pending = ? and created_at < ?", false, true, DELETION_WINDOW.days.ago).find_each do |post|
post.delete!("Unapproved in #{DELETION_WINDOW} days")
rescue PostFlag::Error
# swallow

View File

@ -43,7 +43,7 @@ class PostQueryBuilder
relation = add_array_range_relation(relation, q[:date], "posts.created_at")
relation = add_array_range_relation(relation, q[:age], "posts.created_at")
TagCategory::CATEGORIES.each do |category|
relation = add_array_range_relation(relation, q["#{category}_tag_count".to_sym], "posts.tag_count_#{category}")
relation = add_array_range_relation(relation, q[:"#{category}_tag_count"], "posts.tag_count_#{category}")
end
relation = add_array_range_relation(relation, q[:post_tag_count], "posts.tag_count")

View File

@ -41,7 +41,7 @@ class StatsUpdater
stats[:total_users] = User.count
Danbooru.config.levels.each do |name, level|
stats["#{name.downcase}_users".to_sym] = User.where(level: level).count
stats[:"#{name.downcase}_users"] = User.where(level: level).count
end
stats[:unactivated_users] = User.where.not(email_verification_key: nil).count
stats[:total_dmails] = (Dmail.maximum("id") || 0) / 2
@ -74,7 +74,7 @@ class StatsUpdater
stats[:total_tags] = Tag.count
TagCategory::CATEGORIES.each do |cat|
stats["#{cat}_tags".to_sym] = Tag.where(category: TagCategory::MAPPING[cat]).count
stats[:"#{cat}_tags"] = Tag.where(category: TagCategory::MAPPING[cat]).count
end
Cache.redis.set("e6stats", stats.to_json)

View File

@ -66,7 +66,7 @@ class StorageManager
delete(file_path(md5, file_ext, type, false))
delete(file_path(md5, file_ext, type, true))
end
Danbooru.config.video_rescales.each do |k,v|
Danbooru.config.video_rescales.each_key do |k|
['mp4','webm'].each do |ext|
delete(file_path(md5, ext, :scaled, false, scale_factor: k.to_s))
delete(file_path(md5, ext, :scaled, true, scale_factor: k.to_s))

View File

@ -33,7 +33,7 @@ class StorageManager::Local < StorageManager
move_file(path, new_path)
end
return unless post.is_video?
Danbooru.config.video_rescales.each do |k,v|
Danbooru.config.video_rescales.each_key do |k|
['mp4','webm'].each do |ext|
path = file_path(post, ext, :scaled, false, scale_factor: k.to_s)
new_path = file_path(post, ext, :scaled, true, scale_factor: k.to_s)
@ -52,7 +52,7 @@ class StorageManager::Local < StorageManager
move_file(path, new_path)
end
return unless post.is_video?
Danbooru.config.video_rescales.each do |k,v|
Danbooru.config.video_rescales.each_key do |k|
['mp4','webm'].each do |ext|
path = file_path(post, ext, :scaled, true, scale_factor: k.to_s)
new_path = file_path(post, ext, :scaled, false, scale_factor: k.to_s)

View File

@ -32,7 +32,7 @@ class TagNameValidator < ActiveModel::EachValidator
record.errors.add(attribute, "'#{value}' cannot contain non-printable characters")
when /\A[-~+_`(){}\[\]\/]/
record.errors.add(attribute, "'#{value}' cannot begin with a '#{value[0]}'")
when /\A(#{TagQuery::METATAGS.join("|")}):(.+)\z/i
when /\A(#{TagQuery::METATAGS.join('|')}):(.+)\z/i
record.errors.add(attribute, "'#{value}' cannot begin with '#{$1}:'")
when /\A(#{Tag.categories.regexp}):(.+)\z/i
record.errors.add(attribute, "'#{value}' cannot begin with '#{$1}:'")

View File

@ -278,7 +278,7 @@ class ApplicationRecord < ActiveRecord::Base
class_methods do
def user_status_counter(counter_name, options = {})
class_eval do
belongs_to :user_status, **{foreign_key: :creator_id, primary_key: :user_id, counter_cache: counter_name}.merge(options)
belongs_to :user_status, foreign_key: :creator_id, primary_key: :user_id, counter_cache: counter_name, **options
end
end
@ -334,9 +334,9 @@ class ApplicationRecord < ActiveRecord::Base
define_method "#{name}=" do |value|
if value.respond_to?(:to_str)
super value.to_str.scan(parse).flatten.map(&cast)
super(value.to_str.scan(parse).flatten.map(&cast))
elsif value.respond_to?(:to_a)
super value.to_a
super(value.to_a)
else
raise ArgumentError, "#{name} must be a String or an Array"
end

View File

@ -41,6 +41,6 @@ class HelpPage < ApplicationRecord
end
def self.help_index
Cache.fetch("help_index", expires_in: 12.hours) { HelpPage.all.order(:name).to_a }
Cache.fetch("help_index", expires_in: 12.hours) { HelpPage.order(:name).to_a }
end
end

View File

@ -174,7 +174,7 @@ class Note < ApplicationRecord
def self.undo_changes_by_user(vandal_id)
transaction do
note_ids = NoteVersion.where(:updater_id => vandal_id).select("note_id").distinct.map(&:note_id)
note_ids = NoteVersion.where(updater_id: vandal_id).distinct.pluck(:note_id)
NoteVersion.where(["updater_id = ?", vandal_id]).delete_all
note_ids.each do |note_id|
note = Note.find(note_id)

View File

@ -163,7 +163,7 @@ class PostFlag < ApplicationRecord
# Update parent flags on parent post
parent_post.update_has_children_flag
# Update parent flags on old parent post, if it exists
Post.find(old_parent_id).update_has_children_flag if (old_parent_id && parent_post.id != old_parent_id)
Post.find(old_parent_id).update_has_children_flag if old_parent_id && parent_post.id != old_parent_id
self.reason = "Inferior version/duplicate of post ##{parent_post.id}"
else
self.reason = MAPPED_REASONS[reason_name]

View File

@ -91,9 +91,9 @@ class TagAlias < TagRelationship
def self.to_aliased_query(query, overrides: nil)
# Remove tag types (newline syntax)
query.gsub!(/(^| )(-)?(#{TagCategory::MAPPING.keys.sort_by { |x| -x.size }.join("|")}):([\S])/i, '\1\2\4')
query.gsub!(/(^| )(-)?(#{TagCategory::MAPPING.keys.sort_by { |x| -x.size }.join('|')}):([\S])/i, '\1\2\4')
# Remove tag types (comma syntax)
query.gsub!(/, (-)?(#{TagCategory::MAPPING.keys.sort_by { |x| -x.size }.join("|")}):([\S])/i, ', \1\3')
query.gsub!(/, (-)?(#{TagCategory::MAPPING.keys.sort_by { |x| -x.size }.join('|')}):([\S])/i, ', \1\3')
lines = query.downcase.split("\n")
collected_tags = []
lines.each do |line|

View File

@ -442,9 +442,9 @@ class User < ApplicationRecord
end
def self.create_user_throttle(name, limiter, checker, newbie_duration)
define_method("#{name}_limit".to_sym, limiter)
define_method(:"#{name}_limit", limiter)
define_method("can_#{name}_with_reason".to_sym) do
define_method(:"can_#{name}_with_reason") do
return true if Danbooru.config.disable_throttles?
return send(checker) if checker && send(checker)
return :REJ_NEWBIE if newbie_duration && younger_than(newbie_duration)

View File

@ -60,7 +60,7 @@ class UserPresenter
end
def favorites
ids = Favorite.select(:post_id).where(user_id: user.id).order(created_at: :desc).limit(50).map(&:post_id)[0..5]
ids = Favorite.where(user_id: user.id).order(created_at: :desc).limit(50).pluck(:post_id)[0..5]
Post.where(id: ids)
end

View File

@ -9,7 +9,7 @@
<th>Action</th>
</thead>
<tbody>
<% @invites.where.not(status: "cooldown").each do |m| %>
<% @invites.where.not(status: "cooldown").find_each do |m| %>
<% if m.post_set.is_public %>
<tr>
<td><%= link_to m.post_set.name, post_set_path(m.post_set) %></td>

View File

@ -26,7 +26,7 @@
<div id="tag-string-editor"></div>
<%= f.input :locked_tags, label: "Locked Tags", autocomplete: "tag-edit", input_html: { value: (post.locked_tags || ""), spellcheck: false, size: "60x2", disabled: !CurrentUser.is_admin? } %>
<%= f.input :locked_tags, label: "Locked Tags", autocomplete: "tag-edit", input_html: { value: post.locked_tags || "", spellcheck: false, size: "60x2", disabled: !CurrentUser.is_admin? } %>
</div>
<% if post.is_rating_locked? %>

View File

@ -7,8 +7,8 @@ UserStatus.find_each do |user_status|
end
# post ids who have two replacements, one approved, one original
PostReplacement.select(:post_id).where(status: ["approved", "original"]).group(:post_id)
.having("count(post_id) = 2").map(&:post_id).each do |post_id|
PostReplacement.where(status: %w[approved original]).group(:post_id)
.having("count(post_id) = 2").pluck(:post_id).each do |post_id|
replacements = PostReplacement.where(post_id: post_id).order(:status)
approved = replacements[0]