DEV: Remove logical OR assignment of constants (#29201)

Constants should always be only assigned once. The logical OR assignment
of a constant is a relic of the past before we used zeitwerk for
autoloading and had bugs where a file could be loaded twice resulting in
constant redefinition warnings.
This commit is contained in:
Alan Guo Xiang Tan
2024-10-16 10:09:07 +08:00
committed by GitHub
parent f3f37c9019
commit 322a3be2db
112 changed files with 267 additions and 267 deletions

View File

@ -1,8 +1,8 @@
# frozen_string_literal: true
class Chat::Api::ChannelsController < Chat::ApiController
CHANNEL_EDITABLE_PARAMS ||= %i[name description slug threading_enabled]
CATEGORY_CHANNEL_EDITABLE_PARAMS ||= %i[auto_join_users allow_channel_wide_mentions]
CHANNEL_EDITABLE_PARAMS = %i[name description slug threading_enabled]
CATEGORY_CHANNEL_EDITABLE_PARAMS = %i[auto_join_users allow_channel_wide_mentions]
def index
permitted = params.permit(:filter, :limit, :offset, :status)

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropOldChatMessagePostIdActionCodeColumns < ActiveRecord::Migration[7.0]
DROPPED_COLUMNS ||= { chat_messages: %i[post_id action_code] }
DROPPED_COLUMNS = { chat_messages: %i[post_id action_code] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }

View File

@ -5,7 +5,7 @@ require "migration/table_dropper"
# usage has been dropped in https://github.com/discourse/discourse-chat/commit/1c110b71b28411dc7ac3ab9e3950e0bbf38d7970
# but table never got dropped
class DropUserChatChannelLastReads < ActiveRecord::Migration[7.0]
DROPPED_TABLES ||= %i[user_chat_channel_last_reads]
DROPPED_TABLES = %i[user_chat_channel_last_reads]
def up
DROPPED_TABLES.each { |table| Migration::TableDropper.execute_drop(table) }

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropChatIsolatedFromUserOptions < ActiveRecord::Migration[7.0]
DROPPED_COLUMNS ||= { user_options: %i[chat_isolated] }
DROPPED_COLUMNS = { user_options: %i[chat_isolated] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropChatUploads < ActiveRecord::Migration[7.0]
DROPPED_TABLES ||= %i[chat_uploads]
DROPPED_TABLES = %i[chat_uploads]
def up
DROPPED_TABLES.each { |table| Migration::TableDropper.execute_drop(table) }

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropNotificationIdFromChatMentions < ActiveRecord::Migration[7.0]
DROPPED_COLUMNS ||= { chat_mentions: %i[notification_id] }
DROPPED_COLUMNS = { chat_mentions: %i[notification_id] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropUserIdFromChatMentions < ActiveRecord::Migration[7.0]
DROPPED_COLUMNS ||= { chat_mentions: %i[user_id] }
DROPPED_COLUMNS = { chat_mentions: %i[user_id] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropChatChannelsLastMessageSentAt < ActiveRecord::Migration[7.0]
DROPPED_COLUMNS ||= { chat_channels: %i[last_message_sent_at] }
DROPPED_COLUMNS = { chat_channels: %i[last_message_sent_at] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }

View File

@ -5,9 +5,9 @@ class MigratePollsData < ActiveRecord::Migration[5.2]
PG::Connection.escape_string(text)
end
POLL_TYPES ||= { "regular" => 0, "multiple" => 1, "number" => 2 }
POLL_TYPES = { "regular" => 0, "multiple" => 1, "number" => 2 }
PG_INTEGER_MAX ||= 2_147_483_647
PG_INTEGER_MAX = 2_147_483_647
def up
# Ensure we don't have duplicate polls

View File

@ -2,7 +2,7 @@
module DiscoursePoll
class PollsUpdater
POLL_ATTRIBUTES ||= %w[close_at max min results status step type visibility title groups]
POLL_ATTRIBUTES = %w[close_at max min results status step type visibility title groups]
def self.update(post, polls)
::Poll.transaction do

View File

@ -18,10 +18,10 @@ hide_plugin
after_initialize do
module ::DiscoursePoll
PLUGIN_NAME ||= "poll"
DATA_PREFIX ||= "data-poll-"
HAS_POLLS ||= "has_polls"
DEFAULT_POLL_NAME ||= "poll"
PLUGIN_NAME = "poll"
DATA_PREFIX = "data-poll-"
HAS_POLLS = "has_polls"
DEFAULT_POLL_NAME = "poll"
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME