0
0
Fork 0

Autofix Rubocop remaining Layout rules (#23679)

This commit is contained in:
Nick Schonning 2023-02-20 00:58:28 -05:00 committed by GitHub
parent d2dcb6c45a
commit 717683d1c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
117 changed files with 265 additions and 261 deletions

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: accounts
@ -539,6 +540,7 @@ class Account < ApplicationRecord
def ensure_keys!
return unless local? && private_key.blank? && public_key.blank?
generate_keys
save!
end

View file

@ -14,8 +14,8 @@ class Account::Field < ActiveModelSerializers::Model
@account = account
super(
name: sanitize(attributes['name']),
value: sanitize(attributes['value']),
name: sanitize(attributes['name']),
value: sanitize(attributes['value']),
verified_at: attributes['verified_at']&.to_datetime,
)
end

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: account_conversations
@ -107,6 +108,7 @@ class AccountConversation < ApplicationRecord
def push_to_streaming_api
return if destroyed? || !subscribed_to_timeline?
PushConversationWorker.perform_async(id)
end

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: account_domain_blocks

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: account_moderation_notes

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: account_notes

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: account_pins

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: account_stats

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: account_summaries

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: account_warnings
@ -17,13 +18,13 @@
class AccountWarning < ApplicationRecord
enum action: {
none: 0,
disable: 1_000,
none: 0,
disable: 1_000,
mark_statuses_as_sensitive: 1_250,
delete_statuses: 1_500,
sensitive: 2_000,
silence: 3_000,
suspend: 4_000,
delete_statuses: 1_500,
sensitive: 2_000,
silence: 3_000,
suspend: 4_000,
}, _suffix: :action
before_validation :before_validate

View file

@ -56,6 +56,7 @@ class Admin::Import
def validate_data
return if data.nil?
errors.add(:data, I18n.t('imports.errors.over_rows_processing_limit', count: ROWS_PROCESSING_LIMIT)) if csv_row_count > ROWS_PROCESSING_LIMIT
rescue CSV::MalformedCSVError => e
errors.add(:data, I18n.t('imports.errors.invalid_csv_file', error: e.message))

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: backups

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: blocks

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: bookmarks

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: canonical_email_blocks

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: conversations

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: conversation_mutes

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: custom_emojis

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: custom_filters
@ -101,6 +102,7 @@ class CustomFilter < ApplicationRecord
status_matches = [status.id, status.reblog_of_id].compact & rules[:status_ids] if rules[:status_ids].present?
next if keyword_matches.blank? && status_matches.blank?
FilterResultPresenter.new(filter: filter, keyword_matches: keyword_matches, status_matches: status_matches)
end
end
@ -111,6 +113,7 @@ class CustomFilter < ApplicationRecord
def invalidate_cache!
return unless @should_invalidate_cache
@should_invalidate_cache = false
Rails.cache.delete("filters:v3:#{account_id}")

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: custom_filter_keywords

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: custom_filter_statuses

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: devices

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: domain_blocks

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: email_domain_blocks

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: encrypted_messages

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: favourites
@ -38,6 +39,7 @@ class Favourite < ApplicationRecord
def decrement_cache_counters
return if association(:status).loaded? && status.marked_for_destruction?
status&.decrement_count!(:favourites_count)
end

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: featured_tags

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: follows

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: follow_recommendations

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: follow_recommendation_suppressions

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: follow_requests

View file

@ -128,6 +128,7 @@ class Form::AdminSettings
def validate_site_uploads
UPLOAD_KEYS.each do |key|
next unless instance_variable_defined?("@#{key}")
upload = instance_variable_get("@#{key}")
next if upload.valid?

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: identities

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: imports

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: instances

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: invites

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: ip_blocks

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: lists

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: list_accounts

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: login_activities

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: media_attachments
@ -372,7 +373,7 @@ class MediaAttachment < ApplicationRecord
return {} if width.nil?
{
width: width,
width: width,
height: height,
size: "#{width}x#{height}",
aspect: width.to_f / height,

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: mentions

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: mutes

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: notifications
@ -19,12 +20,12 @@ class Notification < ApplicationRecord
include Paginable
LEGACY_TYPE_CLASS_MAP = {
'Mention' => :mention,
'Status' => :reblog,
'Follow' => :follow,
'Mention' => :mention,
'Status' => :reblog,
'Follow' => :follow,
'FollowRequest' => :follow_request,
'Favourite' => :favourite,
'Poll' => :poll,
'Favourite' => :favourite,
'Poll' => :poll,
}.freeze
TYPES = %i(

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: one_time_keys

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: polls
@ -74,9 +75,9 @@ class Poll < ApplicationRecord
def initialize(poll, id, title, votes_count)
super(
poll: poll,
id: id,
title: title,
poll: poll,
id: id,
title: title,
votes_count: votes_count,
)
end
@ -105,6 +106,7 @@ class Poll < ApplicationRecord
def reset_parent_cache
return if status_id.nil?
Rails.cache.delete("statuses/#{status_id}")
end

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: poll_votes

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: preview_cards

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: preview_card_providers

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: relays

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: reports

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: report_notes

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: session_activations
@ -51,6 +52,7 @@ class SessionActivation < ApplicationRecord
def deactivate(id)
return unless id
where(session_id: id).destroy_all
end

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: settings
@ -30,6 +31,7 @@ class Setting < RailsSettings::Base
default_value = default_settings[key]
return default_value.with_indifferent_access.merge!(db_val.value) if default_value.is_a?(Hash)
db_val.value
else
default_settings[key]
@ -43,6 +45,7 @@ class Setting < RailsSettings::Base
default_settings.each do |key, default_value|
next if records.key?(key) || default_value.is_a?(Hash)
records[key] = Setting.new(var: key, value: default_value)
end
@ -51,6 +54,7 @@ class Setting < RailsSettings::Base
def default_settings
return {} unless RailsSettings::Default.enabled?
RailsSettings::Default.instance
end
end

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: site_uploads

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: statuses

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: status_edits
@ -45,6 +46,7 @@ class StatusEdit < ApplicationRecord
def emojis
return @emojis if defined?(@emojis)
@emojis = CustomEmoji.from_text([spoiler_text, text].join(' '), status.account.domain)
end

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: status_pins

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: status_stats

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: tags

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: unavailable_domains

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: users
@ -492,12 +493,14 @@ class User < ApplicationRecord
def sanitize_languages
return if chosen_languages.nil?
chosen_languages.reject!(&:blank?)
self.chosen_languages = nil if chosen_languages.empty?
end
def sanitize_role
return if role.nil?
self.role = nil if role.everyone?
end
@ -516,6 +519,7 @@ class User < ApplicationRecord
def notify_staff_about_pending_account!
User.those_who_can(:manage_users).includes(:account).find_each do |u|
next unless u.allows_pending_account_emails?
AdminMailer.new_pending_account(u.account, self).deliver_later
end
end

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: user_ips

View file

@ -163,6 +163,7 @@ class UserRole < ApplicationRecord
def in_permissions?(privilege)
raise ArgumentError, "Unknown privilege: #{privilege}" unless FLAGS.key?(privilege)
computed_permissions & FLAGS[privilege] == FLAGS[privilege]
end
@ -172,6 +173,7 @@ class UserRole < ApplicationRecord
def validate_own_role_edition
return unless defined?(@current_account) && @current_account.user_role.id == id
errors.add(:permissions_as_keys, :own_role) if permissions_changed?
errors.add(:position, :own_role) if position_changed?
end

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: web_push_subscriptions

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: web_settings

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: webauthn_credentials