Autofix Rubocop Rails/EnumHash (#23737)
This commit is contained in:
parent
44a7d87cb1
commit
63e6353886
|
@ -1871,22 +1871,6 @@ Rails/DuplicateAssociation:
|
||||||
- 'app/serializers/activitypub/collection_serializer.rb'
|
- 'app/serializers/activitypub/collection_serializer.rb'
|
||||||
- 'app/serializers/activitypub/note_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
|
# Offense count: 76
|
||||||
# Configuration parameters: EnforcedStyle.
|
# Configuration parameters: EnforcedStyle.
|
||||||
# SupportedStyles: slashes, arguments
|
# SupportedStyles: slashes, arguments
|
||||||
|
|
|
@ -78,8 +78,8 @@ class Account < ApplicationRecord
|
||||||
include DomainMaterializable
|
include DomainMaterializable
|
||||||
include AccountMerging
|
include AccountMerging
|
||||||
|
|
||||||
enum protocol: [:ostatus, :activitypub]
|
enum protocol: { ostatus: 0, activitypub: 1 }
|
||||||
enum suspension_origin: [:local, :remote], _prefix: true
|
enum suspension_origin: { local: 0, remote: 1 }, _prefix: true
|
||||||
|
|
||||||
validates :username, presence: true
|
validates :username, presence: true
|
||||||
validates_with UniqueUsernameValidator, if: -> { will_save_change_to_username? }
|
validates_with UniqueUsernameValidator, if: -> { will_save_change_to_username? }
|
||||||
|
|
|
@ -30,7 +30,7 @@ class CustomFilter < ApplicationRecord
|
||||||
include Expireable
|
include Expireable
|
||||||
include Redisable
|
include Redisable
|
||||||
|
|
||||||
enum action: [:warn, :hide], _suffix: :action
|
enum action: { warn: 0, hide: 1 }, _suffix: :action
|
||||||
|
|
||||||
belongs_to :account
|
belongs_to :account
|
||||||
has_many :keywords, class_name: 'CustomFilterKeyword', inverse_of: :custom_filter, dependent: :destroy
|
has_many :keywords, class_name: 'CustomFilterKeyword', inverse_of: :custom_filter, dependent: :destroy
|
||||||
|
|
|
@ -20,7 +20,7 @@ class DomainBlock < ApplicationRecord
|
||||||
include DomainNormalizable
|
include DomainNormalizable
|
||||||
include DomainMaterializable
|
include DomainMaterializable
|
||||||
|
|
||||||
enum severity: [:silence, :suspend, :noop]
|
enum severity: { silence: 0, suspend: 1, noop: 2 }
|
||||||
|
|
||||||
validates :domain, presence: true, uniqueness: true, domain: true
|
validates :domain, presence: true, uniqueness: true, domain: true
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ class Import < ApplicationRecord
|
||||||
|
|
||||||
belongs_to :account
|
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 :type, presence: true
|
||||||
validates_with ImportValidator, on: :create
|
validates_with ImportValidator, on: :create
|
||||||
|
|
|
@ -16,7 +16,7 @@ class List < ApplicationRecord
|
||||||
|
|
||||||
PER_ACCOUNT_LIMIT = 50
|
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
|
belongs_to :account, optional: true
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,8 @@ class MediaAttachment < ApplicationRecord
|
||||||
|
|
||||||
include Attachmentable
|
include Attachmentable
|
||||||
|
|
||||||
enum type: [:image, :gifv, :video, :unknown, :audio]
|
enum type: { :image => 0, :gifv => 1, :video => 2, :unknown => 3, :audio => 4 }
|
||||||
enum processing: [:queued, :in_progress, :complete, :failed], _prefix: true
|
enum processing: { :queued => 0, :in_progress => 1, :complete => 2, :failed => 3 }, _prefix: true
|
||||||
|
|
||||||
MAX_DESCRIPTION_LENGTH = 1_500
|
MAX_DESCRIPTION_LENGTH = 1_500
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@ class PreviewCard < ApplicationRecord
|
||||||
|
|
||||||
self.inheritance_column = false
|
self.inheritance_column = false
|
||||||
|
|
||||||
enum type: [:link, :photo, :video, :rich]
|
enum type: { link: 0, photo: 1, video: 2, rich: 3 }
|
||||||
enum link_type: [:unknown, :article]
|
enum link_type: { unknown: 0, article: 1 }
|
||||||
|
|
||||||
has_and_belongs_to_many :statuses
|
has_and_belongs_to_many :statuses
|
||||||
has_one :trend, class_name: 'PreviewCardTrend', inverse_of: :preview_card, dependent: :destroy
|
has_one :trend, class_name: 'PreviewCardTrend', inverse_of: :preview_card, dependent: :destroy
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
class Relay < ApplicationRecord
|
class Relay < ApplicationRecord
|
||||||
validates :inbox_url, presence: true, uniqueness: true, url: true, if: :will_save_change_to_inbox_url?
|
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 }
|
scope :enabled, -> { accepted }
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ class Status < ApplicationRecord
|
||||||
|
|
||||||
update_index('statuses', :proper)
|
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
|
belongs_to :application, class_name: 'Doorkeeper::Application', optional: true
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue