diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c452d1bd2c..7cb4d55e04 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1871,22 +1871,6 @@ Rails/DuplicateAssociation: - 'app/serializers/activitypub/collection_serializer.rb' - 'app/serializers/activitypub/note_serializer.rb' -# Offense count: 12 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/EnumHash: - Exclude: - - 'app/models/account.rb' - - 'app/models/custom_filter.rb' - - 'app/models/domain_block.rb' - - 'app/models/import.rb' - - 'app/models/list.rb' - - 'app/models/media_attachment.rb' - - 'app/models/preview_card.rb' - - 'app/models/relay.rb' - - 'app/models/status.rb' - # Offense count: 76 # Configuration parameters: EnforcedStyle. # SupportedStyles: slashes, arguments diff --git a/app/models/account.rb b/app/models/account.rb index 2c0cd577e6..d33110d55e 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -78,8 +78,8 @@ class Account < ApplicationRecord include DomainMaterializable include AccountMerging - enum protocol: [:ostatus, :activitypub] - enum suspension_origin: [:local, :remote], _prefix: true + enum protocol: { ostatus: 0, activitypub: 1 } + enum suspension_origin: { local: 0, remote: 1 }, _prefix: true validates :username, presence: true validates_with UniqueUsernameValidator, if: -> { will_save_change_to_username? } diff --git a/app/models/custom_filter.rb b/app/models/custom_filter.rb index b70e53bd53..781bf4db88 100644 --- a/app/models/custom_filter.rb +++ b/app/models/custom_filter.rb @@ -30,7 +30,7 @@ class CustomFilter < ApplicationRecord include Expireable include Redisable - enum action: [:warn, :hide], _suffix: :action + enum action: { warn: 0, hide: 1 }, _suffix: :action belongs_to :account has_many :keywords, class_name: 'CustomFilterKeyword', inverse_of: :custom_filter, dependent: :destroy diff --git a/app/models/domain_block.rb b/app/models/domain_block.rb index 8e298ac9d7..190f5ba2e4 100644 --- a/app/models/domain_block.rb +++ b/app/models/domain_block.rb @@ -20,7 +20,7 @@ class DomainBlock < ApplicationRecord include DomainNormalizable include DomainMaterializable - enum severity: [:silence, :suspend, :noop] + enum severity: { silence: 0, suspend: 1, noop: 2 } validates :domain, presence: true, uniqueness: true, domain: true diff --git a/app/models/import.rb b/app/models/import.rb index 00a54892ef..cd33eb07b0 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -24,7 +24,7 @@ class Import < ApplicationRecord belongs_to :account - enum type: [:following, :blocking, :muting, :domain_blocking, :bookmarks] + enum type: { following: 0, blocking: 1, muting: 2, domain_blocking: 3, bookmarks: 4 } validates :type, presence: true validates_with ImportValidator, on: :create diff --git a/app/models/list.rb b/app/models/list.rb index cdc6ebdb37..7b8cf66362 100644 --- a/app/models/list.rb +++ b/app/models/list.rb @@ -16,7 +16,7 @@ class List < ApplicationRecord PER_ACCOUNT_LIMIT = 50 - enum replies_policy: [:list, :followed, :none], _prefix: :show + enum replies_policy: { list: 0, followed: 1, none: 2 }, _prefix: :show belongs_to :account, optional: true diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb index 5916b0b4b3..c6f2352e03 100644 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@ -33,8 +33,8 @@ class MediaAttachment < ApplicationRecord include Attachmentable - enum type: [:image, :gifv, :video, :unknown, :audio] - enum processing: [:queued, :in_progress, :complete, :failed], _prefix: true + enum type: { :image => 0, :gifv => 1, :video => 2, :unknown => 3, :audio => 4 } + enum processing: { :queued => 0, :in_progress => 1, :complete => 2, :failed => 3 }, _prefix: true MAX_DESCRIPTION_LENGTH = 1_500 diff --git a/app/models/preview_card.rb b/app/models/preview_card.rb index 56ca62d5ec..d25fe6dad1 100644 --- a/app/models/preview_card.rb +++ b/app/models/preview_card.rb @@ -44,8 +44,8 @@ class PreviewCard < ApplicationRecord self.inheritance_column = false - enum type: [:link, :photo, :video, :rich] - enum link_type: [:unknown, :article] + enum type: { link: 0, photo: 1, video: 2, rich: 3 } + enum link_type: { unknown: 0, article: 1 } has_and_belongs_to_many :statuses has_one :trend, class_name: 'PreviewCardTrend', inverse_of: :preview_card, dependent: :destroy diff --git a/app/models/relay.rb b/app/models/relay.rb index c66bfe4ffe..e9c425743f 100644 --- a/app/models/relay.rb +++ b/app/models/relay.rb @@ -14,7 +14,7 @@ class Relay < ApplicationRecord validates :inbox_url, presence: true, uniqueness: true, url: true, if: :will_save_change_to_inbox_url? - enum state: [:idle, :pending, :accepted, :rejected] + enum state: { idle: 0, pending: 1, accepted: 2, rejected: 3 } scope :enabled, -> { accepted } diff --git a/app/models/status.rb b/app/models/status.rb index e0ad291035..44a297a088 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -48,7 +48,7 @@ class Status < ApplicationRecord update_index('statuses', :proper) - enum visibility: [:public, :unlisted, :private, :direct, :limited], _suffix: :visibility + enum visibility: { public: 0, unlisted: 1, private: 2, direct: 3, limited: 4 }, _suffix: :visibility belongs_to :application, class_name: 'Doorkeeper::Application', optional: true