Autofix Rubocop Style/HashAsLastArrayItem

https://docs.rubocop.org/rubocop/cops_style.html#stylehashaslastarrayitem
pull/23853/head
Nick Schonning 2023-02-23 23:06:36 -05:00
parent 2b10b0e027
commit 415e1fac4a
No known key found for this signature in database
GPG Key ID: 5DDAAD9C9AAFFD9F
8 changed files with 14 additions and 17 deletions

View File

@ -12,9 +12,6 @@ Style/FormatStringToken:
merge: merge:
- AllowedMethods - AllowedMethods
Style/HashAsLastArrayItem:
Enabled: false
Style/HashSyntax: Style/HashSyntax:
EnforcedShorthandSyntax: either EnforcedShorthandSyntax: either
EnforcedStyle: ruby19_no_mixed_keys EnforcedStyle: ruby19_no_mixed_keys

View File

@ -59,7 +59,7 @@ module Admin
end end
def set_statuses def set_statuses
@statuses = Admin::StatusFilter.new(@account, filter_params).results.preload(:application, :preloadable_poll, :media_attachments, active_mentions: :account, reblog: [:account, :application, :preloadable_poll, :media_attachments, active_mentions: :account]).page(params[:page]).per(PER_PAGE) @statuses = Admin::StatusFilter.new(@account, filter_params).results.preload(:application, :preloadable_poll, :media_attachments, active_mentions: :account, reblog: [:account, :application, :preloadable_poll, :media_attachments, { active_mentions: :account }]).page(params[:page]).per(PER_PAGE)
end end
def filter_params def filter_params

View File

@ -38,15 +38,15 @@ class Api::V1::ConversationsController < Api::BaseController
def paginated_conversations def paginated_conversations
AccountConversation.where(account: current_account) AccountConversation.where(account: current_account)
.includes( .includes(
account: [:account_stat, user: :role], account: [:account_stat, { user: :role }],
last_status: [ last_status: [
:media_attachments, :media_attachments,
:status_stat, :status_stat,
:tags, :tags,
{ {
preview_cards_status: { preview_card: { author_account: [:account_stat, user: :role] } }, preview_cards_status: { preview_card: { author_account: [:account_stat, { user: :role }] } },
active_mentions: :account, active_mentions: :account,
account: [:account_stat, user: :role], account: [:account_stat, { user: :role }],
}, },
] ]
) )

View File

@ -169,7 +169,7 @@ class Api::V1::StatusesController < Api::BaseController
:multiple, :multiple,
:hide_totals, :hide_totals,
:expires_in, :expires_in,
options: [], { options: [] },
] ]
) )
end end

View File

@ -48,7 +48,7 @@ module Status::ThreadingConcern
end end
def ancestor_statuses(limit) def ancestor_statuses(limit)
Status.find_by_sql([<<-SQL.squish, id: in_reply_to_id, limit: limit]) Status.find_by_sql([<<-SQL.squish, { id: in_reply_to_id, limit: limit }])
WITH RECURSIVE search_tree(id, in_reply_to_id, path) WITH RECURSIVE search_tree(id, in_reply_to_id, path)
AS ( AS (
SELECT id, in_reply_to_id, ARRAY[id] SELECT id, in_reply_to_id, ARRAY[id]
@ -72,7 +72,7 @@ module Status::ThreadingConcern
depth += 1 if depth.present? depth += 1 if depth.present?
limit += 1 if limit.present? limit += 1 if limit.present?
descendants_with_self = Status.find_by_sql([<<-SQL.squish, id: id, limit: limit, depth: depth]) descendants_with_self = Status.find_by_sql([<<-SQL.squish, { id: id, limit: limit, depth: depth }])
WITH RECURSIVE search_tree(id, path) AS ( WITH RECURSIVE search_tree(id, path) AS (
SELECT id, ARRAY[id] SELECT id, ARRAY[id]
FROM statuses FROM statuses

View File

@ -157,8 +157,8 @@ class Status < ApplicationRecord
:status_stat, :status_stat,
:tags, :tags,
:preloadable_poll, :preloadable_poll,
preview_cards_status: { preview_card: { author_account: [:account_stat, user: :role] } }, preview_cards_status: { preview_card: { author_account: [:account_stat, { user: :role }] } },
account: [:account_stat, user: :role], account: [:account_stat, { user: :role }],
active_mentions: :account, active_mentions: :account,
reblog: [ reblog: [
:application, :application,
@ -167,9 +167,9 @@ class Status < ApplicationRecord
:conversation, :conversation,
:status_stat, :status_stat,
:preloadable_poll, :preloadable_poll,
preview_cards_status: { preview_card: { author_account: [:account_stat, user: :role] } }, { preview_cards_status: { preview_card: { author_account: [:account_stat, { user: :role }] } },
account: [:account_stat, user: :role], account: [:account_stat, { user: :role }],
active_mentions: :account, active_mentions: :account },
], ],
thread: :account thread: :account

View File

@ -10,7 +10,7 @@ class BatchedRemoveStatusService < BaseService
def call(statuses, **options) def call(statuses, **options)
ActiveRecord::Associations::Preloader.new( ActiveRecord::Associations::Preloader.new(
records: statuses, records: statuses,
associations: options[:skip_side_effects] ? :reblogs : [:account, :tags, reblogs: :account] associations: options[:skip_side_effects] ? :reblogs : [:account, :tags, { reblogs: :account }]
).call ).call
statuses_and_reblogs = statuses.flat_map { |status| [status] + status.reblogs } statuses_and_reblogs = statuses.flat_map { |status| [status] + status.reblogs }

View File

@ -153,7 +153,7 @@ class NotifyService < BaseService
# This queries private mentions from the recipient to the sender up in the thread. # This queries private mentions from the recipient to the sender up in the thread.
# This allows up to 100 messages that do not match in the thread, allowing conversations # This allows up to 100 messages that do not match in the thread, allowing conversations
# involving multiple people. # involving multiple people.
Status.count_by_sql([<<-SQL.squish, id: @notification.target_status.in_reply_to_id, recipient_id: @recipient.id, sender_id: @sender.id, depth_limit: 100]) Status.count_by_sql([<<-SQL.squish, { id: @notification.target_status.in_reply_to_id, recipient_id: @recipient.id, sender_id: @sender.id, depth_limit: 100 }])
WITH RECURSIVE ancestors(id, in_reply_to_id, mention_id, path, depth) AS ( WITH RECURSIVE ancestors(id, in_reply_to_id, mention_id, path, depth) AS (
SELECT s.id, s.in_reply_to_id, m.id, ARRAY[s.id], 0 SELECT s.id, s.in_reply_to_id, m.id, ARRAY[s.id], 0
FROM statuses s FROM statuses s