Add an apply Rails/EnumSyntax rubocop rule

This rule was added in rubocop-rails 2.26.0. Applying it allows
us to anticipate the deprecation of the current enum syntax
using keyword arguments, which is set to be removed in Rails
8.0, as mentioned in the rule's own documentation:

https://docs.rubocop.org/rubocop-rails/cops_rails.html#railsenumsyntax
This commit is contained in:
taitus
2024-10-08 15:45:14 +02:00
parent 9283b8b422
commit 3d4f78a424
7 changed files with 9 additions and 6 deletions

View File

@@ -388,6 +388,9 @@ Rails/DynamicFindBy:
- find_by_slug_or_id!
- find_by_manager_login
Rails/EnumSyntax:
Enabled: true
Rails/EnumUniqueness:
Enabled: true

View File

@@ -9,7 +9,7 @@ class Dashboard::Action < ApplicationRecord
class_name: "Dashboard::ExecutedAction"
has_many :proposals, through: :executed_actions
enum action_type: [:proposed_action, :resource]
enum :action_type, [:proposed_action, :resource]
validates :title, presence: true, allow_blank: false, length: { in: 4..80 }

View File

@@ -8,7 +8,7 @@ class Poll
validates :date, presence: true, uniqueness: { scope: [:officer_id, :booth_id, :task] }
validates :task, presence: true
enum task: { vote_collection: 0, recount_scrutiny: 1 }
enum :task, { vote_collection: 0, recount_scrutiny: 1 }
scope :current, -> { where(date: Date.current) }

View File

@@ -2,7 +2,7 @@ class ProgressBar < ApplicationRecord
self.inheritance_column = nil
RANGE = (0..100)
enum kind: %i[primary secondary]
enum :kind, %i[primary secondary]
belongs_to :progressable, polymorphic: true

View File

@@ -1,6 +1,6 @@
class SDG::Phase < ApplicationRecord
include Cardable
enum kind: %w[sensitization planning monitoring]
enum :kind, %w[sensitization planning monitoring]
validates :kind, presence: true, uniqueness: true
def self.[](kind)

View File

@@ -1,5 +1,5 @@
class Tenant < ApplicationRecord
enum schema_type: %w[subdomain domain]
enum :schema_type, %w[subdomain domain]
validates :schema,
presence: true,

View File

@@ -3,7 +3,7 @@ class VotationType < ApplicationRecord
QUESTIONABLE_TYPES = %w[Poll::Question].freeze
enum vote_type: %w[unique multiple]
enum :vote_type, %w[unique multiple]
validates :questionable, presence: true
validates :questionable_type, inclusion: { in: ->(*) { QUESTIONABLE_TYPES }}