Skip to content

A platform for community discussion. Free, open, simple.

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

Alan Guo Xiang Tan322a3be2dbae
diff --git a/app/controllers/admin/themes_controller.rb b/app/controllers/admin/themes_controller.rb
index 5547b13de20..e262230848c 100644
--- a/app/controllers/admin/themes_controller.rb
+++ b/app/controllers/admin/themes_controller.rb
@@ -40,7 +40,7 @@ class Admin::ThemesController < Admin::AdminController
render json: { public_key: k.ssh_public_key }
end
- THEME_CONTENT_TYPES ||= %w[
+ THEME_CONTENT_TYPES = %w[
application/gzip
application/x-gzip
application/x-zip-compressed
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 0b5c46a97ad..94330d14d07 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -56,8 +56,8 @@ class ApplicationController < ActionController::Base
after_action :clean_xml, if: :is_feed_response?
after_action :add_early_hint_header, if: -> { spa_boot_request? }
- HONEYPOT_KEY ||= "HONEYPOT_KEY"
- CHALLENGE_KEY ||= "CHALLENGE_KEY"
+ HONEYPOT_KEY = "HONEYPOT_KEY"
+ CHALLENGE_KEY = "CHALLENGE_KEY"
layout :set_layout
diff --git a/app/controllers/extra_locales_controller.rb b/app/controllers/extra_locales_controller.rb
index 7fb4fab9f64..df2768e8099 100644
--- a/app/controllers/extra_locales_controller.rb
+++ b/app/controllers/extra_locales_controller.rb
@@ -9,8 +9,8 @@ class ExtraLocalesController < ApplicationController
:redirect_to_profile_if_required,
:verify_authenticity_token
- OVERRIDES_BUNDLE ||= "overrides"
- MD5_HASH_LENGTH ||= 32
+ OVERRIDES_BUNDLE = "overrides"
+ MD5_HASH_LENGTH = 32
MF_BUNDLE = "mf"
BUNDLES = [OVERRIDES_BUNDLE, MF_BUNDLE]
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index 81821be4670..fce5dfbcef4 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -595,7 +595,7 @@ class GroupsController < ApplicationController
end
end
- MAX_NOTIFIED_OWNERS ||= 20
+ MAX_NOTIFIED_OWNERS = 20
def request_membership
params.require(:reason)
diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
index 9953e692cf2..bdd2b68831d 100644
--- a/app/controllers/posts_controller.rb
+++ b/app/controllers/posts_controller.rb
@@ -27,7 +27,7 @@ class PostsController < ApplicationController
:check_xhr,
only: %i[markdown_id markdown_num short_link latest user_posts_feed]
- MARKDOWN_TOPIC_PAGE_SIZE ||= 100
+ MARKDOWN_TOPIC_PAGE_SIZE = 100
def markdown_id
markdown Post.find_by(id: params[:id].to_i)
@@ -429,7 +429,7 @@ class PostsController < ApplicationController
render_json_error(e.message)
end
- MAX_POST_REPLIES ||= 20
+ MAX_POST_REPLIES = 20
def replies
params.permit(:after)
diff --git a/app/controllers/presence_controller.rb b/app/controllers/presence_controller.rb
index a4ab2d57e5f..47eace333e8 100644
--- a/app/controllers/presence_controller.rb
+++ b/app/controllers/presence_controller.rb
@@ -5,7 +5,7 @@ class PresenceController < ApplicationController
before_action :ensure_logged_in, only: [:update]
before_action :skip_persist_session
- MAX_CHANNELS_PER_REQUEST ||= 50
+ MAX_CHANNELS_PER_REQUEST = 50
def get
names = params.require(:channels)
diff --git a/app/controllers/robots_txt_controller.rb b/app/controllers/robots_txt_controller.rb
index 0d7d8ee7cd5..c3498b11644 100644
--- a/app/controllers/robots_txt_controller.rb
+++ b/app/controllers/robots_txt_controller.rb
@@ -10,7 +10,7 @@ class RobotsTxtController < ApplicationController
OVERRIDDEN_HEADER = "# This robots.txt file has been customized at /admin/customize/robots\n"
# NOTE: order is important!
- DISALLOWED_PATHS ||= %w[
+ DISALLOWED_PATHS = %w[
/admin/
/auth/
/assets/browser-update*.js
@@ -21,7 +21,7 @@ class RobotsTxtController < ApplicationController
/*?*api_key*
]
- DISALLOWED_WITH_HEADER_PATHS ||= %w[/badges /u/ /my /search /tag/*/l /g /t/*/*.rss /c/*.rss]
+ DISALLOWED_WITH_HEADER_PATHS = %w[/badges /u/ /my /search /tag/*/l /g /t/*/*.rss /c/*.rss]
def index
if (overridden = SiteSetting.overridden_robots_txt.dup).present?
diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb
index 77a53d808a6..1319ae6717d 100644
--- a/app/controllers/static_controller.rb
+++ b/app/controllers/static_controller.rb
@@ -145,7 +145,7 @@ class StaticController < ApplicationController
redirect_to(destination, allow_other_host: false)
end
- FAVICON ||= -"favicon"
+ FAVICON = -"favicon"
# We need to be able to draw our favicon on a canvas, this happens when you enable the feature
# that draws the notification count on top of favicon (per user default off)
diff --git a/app/controllers/user_api_keys_controller.rb b/app/controllers/user_api_keys_controller.rb
index f1bea047542..792f3000b34 100644
--- a/app/controllers/user_api_keys_controller.rb
+++ b/app/controllers/user_api_keys_controller.rb
@@ -9,7 +9,7 @@ class UserApiKeysController < ApplicationController
only: %i[new otp]
skip_before_action :check_xhr, :preload_json
- AUTH_API_VERSION ||= 4
+ AUTH_API_VERSION = 4
def new
if request.head?
diff --git a/app/controllers/users/associate_accounts_controller.rb b/app/controllers/users/associate_accounts_controller.rb
index 371cfbf58c4..393b7ef8bde 100644
--- a/app/controllers/users/associate_accounts_controller.rb
+++ b/app/controllers/users/associate_accounts_controller.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class Users::AssociateAccountsController < ApplicationController
- SECURE_SESSION_PREFIX ||= "omniauth_reconnect"
+ SECURE_SESSION_PREFIX = "omniauth_reconnect"
before_action :ensure_logged_in
diff --git a/app/jobs/regular/export_csv_file.rb b/app/jobs/regular/export_csv_file.rb
index 3d727ad4762..d43b718e318 100644
--- a/app/jobs/regular/export_csv_file.rb
+++ b/app/jobs/regular/export_csv_file.rb
@@ -10,7 +10,7 @@ module Jobs
attr_accessor :current_user
attr_accessor :entity
- HEADER_ATTRS_FOR ||=
+ HEADER_ATTRS_FOR =
HashWithIndifferentAccess.new(
user_list: %w[
id
diff --git a/app/jobs/regular/export_user_archive.rb b/app/jobs/regular/export_user_archive.rb
index 56d0315fbaf..1c3a213d87b 100644
--- a/app/jobs/regular/export_user_archive.rb
+++ b/app/jobs/regular/export_user_archive.rb
@@ -10,7 +10,7 @@ module Jobs
# note: contents provided entirely by user
attr_accessor :extra
- COMPONENTS ||= %w[
+ COMPONENTS = %w[
user_archive
preferences
auth_tokens
@@ -25,7 +25,7 @@ module Jobs
visits
]
- HEADER_ATTRS_FOR ||=
+ HEADER_ATTRS_FOR =
HashWithIndifferentAccess.new(
user_archive: %w[
topic_title
diff --git a/app/jobs/regular/user_email.rb b/app/jobs/regular/user_email.rb
index 33fce796304..112057cd790 100644
--- a/app/jobs/regular/user_email.rb
+++ b/app/jobs/regular/user_email.rb
@@ -93,8 +93,7 @@ module Jobs
@skip_context = { type: type, user_id: user_id, to_address: to_address, post_id: post_id }
end
- NOTIFICATIONS_SENT_BY_MAILING_LIST ||=
- Set.new %w[posted replied mentioned group_mentioned quoted]
+ NOTIFICATIONS_SENT_BY_MAILING_LIST = Set.new %w[posted replied mentioned group_mentioned quoted]
def message_for_email(user, post, type, notification, args = nil)
args ||= {}
diff --git a/app/jobs/scheduled/update_animated_uploads.rb b/app/jobs/scheduled/update_animated_uploads.rb
index 51ea6204a4f..660c8150236 100644
--- a/app/jobs/scheduled/update_animated_uploads.rb
+++ b/app/jobs/scheduled/update_animated_uploads.rb
@@ -4,7 +4,7 @@ module Jobs
class UpdateAnimatedUploads < ::Jobs::Scheduled
every 1.hour
- MAX_PROCESSED_GIF_IMAGES ||= 200
+ MAX_PROCESSED_GIF_IMAGES = 200
def execute(args)
Upload
diff --git a/app/models/admin_dashboard_data.rb b/app/models/admin_dashboard_data.rb
index 8aefd39e301..7b1692024e4 100644
--- a/app/models/admin_dashboard_data.rb
+++ b/app/models/admin_dashboard_data.rb
@@ -6,7 +6,7 @@ class AdminDashboardData
cattr_reader :problem_messages, default: []
# kept for backward compatibility
- GLOBAL_REPORTS ||= []
+ GLOBAL_REPORTS = []
PROBLEM_MESSAGE_PREFIX = "admin-problem:"
SCHEDULED_PROBLEM_STORAGE_KEY = "admin-found-scheduled-problems-list"
diff --git a/app/models/backup_location_site_setting.rb b/app/models/backup_location_site_setting.rb
index 1bdbd2403d6..9c23e0e67aa 100644
--- a/app/models/backup_location_site_setting.rb
+++ b/app/models/backup_location_site_setting.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
class BackupLocationSiteSetting < EnumSiteSetting
- LOCAL ||= "local"
- S3 ||= "s3"
+ LOCAL = "local"
+ S3 = "s3"
def self.valid_value?(val)
values.any? { |v| v[:value] == val }
diff --git a/app/models/concerns/has_custom_fields.rb b/app/models/concerns/has_custom_fields.rb
index eb0e4a0c7ab..f763b7278c1 100644
--- a/app/models/concerns/has_custom_fields.rb
+++ b/app/models/concerns/has_custom_fields.rb
@@ -4,7 +4,7 @@ module HasCustomFields
extend ActiveSupport::Concern
module Helpers
- CUSTOM_FIELD_TRUE ||= %w[1 t true T True TRUE].freeze
+ CUSTOM_FIELD_TRUE = %w[1 t true T True TRUE].freeze
end
class FieldDescriptor < Struct.new(:type, :max_length)
diff --git a/app/models/draft.rb b/app/models/draft.rb
index 8e97aaf512a..9ad6016e78a 100644
--- a/app/models/draft.rb
+++ b/app/models/draft.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
class Draft < ActiveRecord::Base
- NEW_TOPIC ||= "new_topic"
- NEW_PRIVATE_MESSAGE ||= "new_private_message"
- EXISTING_TOPIC ||= "topic_"
+ NEW_TOPIC = "new_topic"
+ NEW_PRIVATE_MESSAGE = "new_private_message"
+ EXISTING_TOPIC = "topic_"
belongs_to :user
diff --git a/app/models/email_log.rb b/app/models/email_log.rb
index c3dc39e0363..1459626ae5b 100644
--- a/app/models/email_log.rb
+++ b/app/models/email_log.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class EmailLog < ActiveRecord::Base
- CRITICAL_EMAIL_TYPES ||=
+ CRITICAL_EMAIL_TYPES =
Set.new %w[
account_created
admin_login
diff --git a/app/models/emoji.rb b/app/models/emoji.rb
index 867767823cb..e4eb76b4979 100644
--- a/app/models/emoji.rb
+++ b/app/models/emoji.rb
@@ -4,9 +4,9 @@ class Emoji
# update this to clear the cache
EMOJI_VERSION = "12"
- FITZPATRICK_SCALE ||= %w[1f3fb 1f3fc 1f3fd 1f3fe 1f3ff]
+ FITZPATRICK_SCALE = %w[1f3fb 1f3fc 1f3fd 1f3fe 1f3ff]
- DEFAULT_GROUP ||= "default"
+ DEFAULT_GROUP = "default"
include ActiveModel::SerializerSupport
diff --git a/app/models/global_setting.rb b/app/models/global_setting.rb
index e58134e7d75..c143dea6838 100644
--- a/app/models/global_setting.rb
+++ b/app/models/global_setting.rb
@@ -5,12 +5,12 @@ class GlobalSetting
define_singleton_method(key) { provider.lookup(key, default) }
end
- VALID_SECRET_KEY ||= /\A[0-9a-f]{128}\z/
+ VALID_SECRET_KEY = /\A[0-9a-f]{128}\z/
# this is named SECRET_TOKEN as opposed to SECRET_KEY_BASE
# for legacy reasons
- REDIS_SECRET_KEY ||= "SECRET_TOKEN"
+ REDIS_SECRET_KEY = "SECRET_TOKEN"
- REDIS_VALIDATE_SECONDS ||= 30
+ REDIS_VALIDATE_SECONDS = 30
# In Rails secret_key_base is used to encrypt the cookie store
# the cookie store contains session data
diff --git a/app/models/imap_sync_log.rb b/app/models/imap_sync_log.rb
index 28f216c4cb2..f5fc0ded5da 100644
--- a/app/models/imap_sync_log.rb
+++ b/app/models/imap_sync_log.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class ImapSyncLog < ActiveRecord::Base
- RETAIN_LOGS_DAYS ||= 5
+ RETAIN_LOGS_DAYS = 5
belongs_to :group
diff --git a/app/models/locale_site_setting.rb b/app/models/locale_site_setting.rb
index 8d48568d675..98028dcfcde 100644
--- a/app/models/locale_site_setting.rb
+++ b/app/models/locale_site_setting.rb
@@ -53,7 +53,7 @@ class LocaleSiteSetting < EnumSiteSetting
@lock.synchronize { @values = @language_names = @supported_locales = nil }
end
- FALLBACKS ||= { en_GB: :en }
+ FALLBACKS = { en_GB: :en }
def self.fallback_locale(locale)
fallback_locale = FALLBACKS[locale.to_sym]
diff --git a/app/models/optimized_image.rb b/app/models/optimized_image.rb
index b3e390efcd9..36c273fddd2 100644
--- a/app/models/optimized_image.rb
+++ b/app/models/optimized_image.rb
@@ -6,7 +6,7 @@ class OptimizedImage < ActiveRecord::Base
# BUMP UP if optimized image algorithm changes
VERSION = 2
- URL_REGEX ||= %r{(/optimized/\dX[/\.\w]*/([a-zA-Z0-9]+)[\.\w]*)}
+ URL_REGEX = %r{(/optimized/\dX[/\.\w]*/([a-zA-Z0-9]+)[\.\w]*)}
def self.lock(upload_id, width, height)
@hostname ||= Discourse.os_hostname
@@ -185,7 +185,7 @@ class OptimizedImage < ActiveRecord::Base
paths.each { |path| raise Discourse::InvalidAccess unless safe_path?(path) }
end
- IM_DECODERS ||= /\A(jpe?g|png|ico|gif|webp|avif)\z/i
+ IM_DECODERS = /\A(jpe?g|png|ico|gif|webp|avif)\z/i
def self.prepend_decoder!(path, ext_path = nil, opts = nil)
opts ||= {}
diff --git a/app/models/post.rb b/app/models/post.rb
index 790338c1e6b..5e86d115364 100644
--- a/app/models/post.rb
+++ b/app/models/post.rb
@@ -77,11 +77,11 @@ class Post < ActiveRecord::Base
:skip_unique_check,
:skip_validation
- MISSING_UPLOADS ||= "missing uploads"
- MISSING_UPLOADS_IGNORED ||= "missing uploads ignored"
- NOTICE ||= "notice"
+ MISSING_UPLOADS = "missing uploads"
+ MISSING_UPLOADS_IGNORED = "missing uploads ignored"
+ NOTICE = "notice"
- SHORT_POST_CHARS ||= 1200
+ SHORT_POST_CHARS = 1200
register_custom_field_type(MISSING_UPLOADS, :json)
register_custom_field_type(MISSING_UPLOADS_IGNORED, :boolean)
diff --git a/app/models/remove_muted_tags_from_latest_site_setting.rb b/app/models/remove_muted_tags_from_latest_site_setting.rb
index fb07d94b7a9..4d5be517bf0 100644
--- a/app/models/remove_muted_tags_from_latest_site_setting.rb
+++ b/app/models/remove_muted_tags_from_latest_site_setting.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
class RemoveMutedTagsFromLatestSiteSetting < EnumSiteSetting
- ALWAYS ||= "always"
- ONLY_MUTED ||= "only_muted"
- NEVER ||= "never"
+ ALWAYS = "always"
+ ONLY_MUTED = "only_muted"
+ NEVER = "never"
def self.valid_value?(val)
values.any? { |v| v[:value] == val }
diff --git a/app/models/topic.rb b/app/models/topic.rb
index 0e6ecd4c8fb..2f68222495e 100644
--- a/app/models/topic.rb
+++ b/app/models/topic.rb
@@ -697,7 +697,7 @@ class Topic < ActiveRecord::Base
!self.closed?
end
- MAX_SIMILAR_BODY_LENGTH ||= 200
+ MAX_SIMILAR_BODY_LENGTH = 200
def self.similar_to(title, raw, user = nil)
return [] if SiteSetting.max_similar_results == 0
@@ -1728,7 +1728,7 @@ class Topic < ActiveRecord::Base
DB.exec(sql, user_id: user.id, topic_id: id) > 0
end
- TIME_TO_FIRST_RESPONSE_SQL ||= <<-SQL
+ TIME_TO_FIRST_RESPONSE_SQL = <<-SQL
SELECT AVG(t.hours)::float AS "hours", t.created_at AS "date"
FROM (
SELECT t.id, t.created_at::date AS created_at, EXTRACT(EPOCH FROM MIN(p.created_at) - t.created_at)::float / 3600.0 AS "hours"
@@ -1741,7 +1741,7 @@ class Topic < ActiveRecord::Base
ORDER BY t.created_at
SQL
- TIME_TO_FIRST_RESPONSE_TOTAL_SQL ||= <<-SQL
+ TIME_TO_FIRST_RESPONSE_TOTAL_SQL = <<-SQL
SELECT AVG(t.hours)::float AS "hours"
FROM (
SELECT t.id, EXTRACT(EPOCH FROM MIN(p.created_at) - t.created_at)::float / 3600.0 AS "hours"
@@ -1787,7 +1787,7 @@ class Topic < ActiveRecord::Base
total.first["hours"].to_f.round(2)
end
- WITH_NO_RESPONSE_SQL ||= <<-SQL
+ WITH_NO_RESPONSE_SQL = <<-SQL
SELECT COUNT(*) as count, tt.created_at AS "date"
FROM (
SELECT t.id, t.created_at::date AS created_at, MIN(p.post_number) first_reply
@@ -1822,7 +1822,7 @@ class Topic < ActiveRecord::Base
builder.query_hash
end
- WITH_NO_RESPONSE_TOTAL_SQL ||= <<-SQL
+ WITH_NO_RESPONSE_TOTAL_SQL = <<-SQL
SELECT COUNT(*) as count
FROM (
SELECT t.id, MIN(p.post_number) first_reply
diff --git a/app/models/user.rb b/app/models/user.rb
index 00e71a234d7..4932dcaddca 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -364,7 +364,7 @@ class User < ActiveRecord::Base
LAST_VISIT = -2
end
- MAX_STAFF_DELETE_POST_COUNT ||= 5
+ MAX_STAFF_DELETE_POST_COUNT = 5
def self.user_tips
@user_tips ||=
@@ -1568,7 +1568,7 @@ class User < ActiveRecord::Base
result
end
- USER_FIELD_PREFIX ||= "user_field_"
+ USER_FIELD_PREFIX = "user_field_"
def user_fields(field_ids = nil)
field_ids = (@all_user_field_ids ||= UserField.pluck(:id)) if field_ids.nil?
@@ -1711,7 +1711,7 @@ class User < ActiveRecord::Base
.pluck(:new_email)
end
- RECENT_TIME_READ_THRESHOLD ||= 60.days
+ RECENT_TIME_READ_THRESHOLD = 60.days
def self.preload_recent_time_read(users)
times =
diff --git a/app/models/user_search.rb b/app/models/user_search.rb
index 6c8f01286bf..0d2205a6649 100644
--- a/app/models/user_search.rb
+++ b/app/models/user_search.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class UserSearch
- MAX_SIZE_PRIORITY_MENTION ||= 500
+ MAX_SIZE_PRIORITY_MENTION = 500
def initialize(term, opts = {})
@term = term.downcase
diff --git a/app/models/user_summary.rb b/app/models/user_summary.rb
index 8156afcc419..311785067b1 100644
--- a/app/models/user_summary.rb
+++ b/app/models/user_summary.rb
@@ -79,7 +79,7 @@ class UserSummary
user_counts(liked_users)
end
- REPLY_ACTIONS ||= [UserAction::RESPONSE, UserAction::QUOTE, UserAction::MENTION]
+ REPLY_ACTIONS = [UserAction::RESPONSE, UserAction::QUOTE, UserAction::MENTION]
def most_replied_to_users
replied_users = {}
diff --git a/app/models/username_validator.rb b/app/models/username_validator.rb
index 20e5262d064..c11c770711e 100644
--- a/app/models/username_validator.rb
+++ b/app/models/username_validator.rb
@@ -40,10 +40,10 @@ class UsernameValidator
errors.empty?
end
- CONFUSING_EXTENSIONS ||= /\.(js|json|css|htm|html|xml|jpg|jpeg|png|gif|bmp|ico|tif|tiff|woff)\z/i
- MAX_CHARS ||= 60
+ CONFUSING_EXTENSIONS = /\.(js|json|css|htm|html|xml|jpg|jpeg|png|gif|bmp|ico|tif|tiff|woff)\z/i
+ MAX_CHARS = 60
- ASCII_INVALID_CHAR_PATTERN ||= /[^\w.-]/
+ ASCII_INVALID_CHAR_PATTERN = /[^\w.-]/
# All Unicode characters except for alphabetic and numeric character, marks and underscores are invalid.
# In addition to that, the following letters and nonspacing marks are invalid:
# (U+034F) Combining Grapheme Joiner
@@ -56,7 +56,7 @@ class UsernameValidator
# (U+FFA0) Halfwidth Hangul Filler
# (U+FE00 - U+FE0F) "Variation Selectors" block
# (U+E0100 - U+E01EF) "Variation Selectors Supplement" block
- UNICODE_INVALID_CHAR_PATTERN ||=
+ UNICODE_INVALID_CHAR_PATTERN =
/
[^\p{Alnum}\p{M}._-]|
[
@@ -72,9 +72,9 @@ class UsernameValidator
\p{In Variation Selectors Supplement}
]
/x
- INVALID_LEADING_CHAR_PATTERN ||= /\A[^\p{Alnum}\p{M}_]+/
- INVALID_TRAILING_CHAR_PATTERN ||= /[^\p{Alnum}\p{M}]+\z/
- REPEATED_SPECIAL_CHAR_PATTERN ||= /[-_.]{2,}/
+ INVALID_LEADING_CHAR_PATTERN = /\A[^\p{Alnum}\p{M}_]+/
+ INVALID_TRAILING_CHAR_PATTERN = /[^\p{Alnum}\p{M}]+\z/
+ REPEATED_SPECIAL_CHAR_PATTERN = /[-_.]{2,}/
private
diff --git a/app/serializers/post_serializer.rb b/app/serializers/post_serializer.rb
index ebb9f45bb7c..4fe30f814bf 100644
--- a/app/serializers/post_serializer.rb
+++ b/app/serializers/post_serializer.rb
@@ -2,7 +2,7 @@
class PostSerializer < BasicPostSerializer
# To pass in additional information we might need
- INSTANCE_VARS ||= %i[
+ INSTANCE_VARS = %i[
parent_post
add_raw
add_title
diff --git a/app/services/badge_granter.rb b/app/services/badge_granter.rb
index d8af5a607a7..10acf35603e 100644
--- a/app/services/badge_granter.rb
+++ b/app/services/badge_granter.rb
@@ -379,7 +379,7 @@ class BadgeGranter
{ errors: e.message }
end
- MAX_ITEMS_FOR_DELTA ||= 200
+ MAX_ITEMS_FOR_DELTA = 200
def self.backfill(badge, opts = nil)
return unless SiteSetting.enable_badges
return unless badge.enabled
diff --git a/app/services/push_notification_pusher.rb b/app/services/push_notification_pusher.rb
index 5ed7f97350f..928181f52be 100644
--- a/app/services/push_notification_pusher.rb
+++ b/app/services/push_notification_pusher.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class PushNotificationPusher
- TOKEN_VALID_FOR_SECONDS ||= 5 * 60
+ TOKEN_VALID_FOR_SECONDS = 5 * 60
CONNECTION_TIMEOUT_SECONDS = 5
def self.push(user, payload)
@@ -108,8 +108,8 @@ class PushNotificationPusher
end
end
- MAX_ERRORS ||= 3
- MIN_ERROR_DURATION ||= 86_400 # 1 day
+ MAX_ERRORS = 3
+ MIN_ERROR_DURATION = 86_400 # 1 day
def self.handle_generic_error(subscription, error, user, endpoint, message)
subscription.error_count += 1
diff --git a/app/services/search_indexer.rb b/app/services/search_indexer.rb
index 1b0aa62e749..9ef1a4b0fcb 100644
--- a/app/services/search_indexer.rb
+++ b/app/services/search_indexer.rb
@@ -405,8 +405,8 @@ class SearchIndexer
html_scrubber.scrubbed.squish
end
- MENTION_CLASSES ||= %w[mention mention-group]
- ATTRIBUTES ||= %w[alt title href data-video-title]
+ MENTION_CLASSES = %w[mention mention-group]
+ ATTRIBUTES = %w[alt title href data-video-title]
def start_element(_name, attributes = [])
attributes = Hash[*attributes.flatten]
diff --git a/app/services/staff_action_logger.rb b/app/services/staff_action_logger.rb
index 29e2f241cb4..9bf89155803 100644
--- a/app/services/staff_action_logger.rb
+++ b/app/services/staff_action_logger.rb
@@ -11,7 +11,7 @@ class StaffActionLogger
raise Discourse::InvalidParameters.new(:admin) unless @admin && @admin.is_a?(User)
end
- USER_FIELDS ||= %i[id username name created_at trust_level last_seen_at last_emailed_at]
+ USER_FIELDS = %i[id username name created_at trust_level last_seen_at last_emailed_at]
def log_user_deletion(deleted_user, opts = {})
unless deleted_user && deleted_user.is_a?(User)
@@ -410,7 +410,7 @@ class StaffActionLogger
)
end
- BADGE_FIELDS ||= %i[
+ BADGE_FIELDS = %i[
id
name
description
diff --git a/app/services/word_watcher.rb b/app/services/word_watcher.rb
index c71706b692f..a0782130e49 100644
--- a/app/services/word_watcher.rb
+++ b/app/services/word_watcher.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
class WordWatcher
- REPLACEMENT_LETTER ||= CGI.unescape_html("&#9632;")
- CACHE_VERSION ||= 3
+ REPLACEMENT_LETTER = CGI.unescape_html("&#9632;")
+ CACHE_VERSION = 3
def initialize(raw)
@raw = raw
diff --git a/db/migrate/20180917024729_remove_superfluous_columns.rb b/db/migrate/20180917024729_remove_superfluous_columns.rb
index cc2f87a31de..734279ca5cf 100644
--- a/db/migrate/20180917024729_remove_superfluous_columns.rb
+++ b/db/migrate/20180917024729_remove_superfluous_columns.rb
@@ -4,7 +4,7 @@ require "migration/column_dropper"
require "badge_posts_view_manager"
class RemoveSuperfluousColumns < ActiveRecord::Migration[5.2]
- DROPPED_COLUMNS ||= {
+ DROPPED_COLUMNS = {
user_profiles: %i[card_image_badge_id],
categories: %i[logo_url background_url suppress_from_homepage],
groups: %i[visible public alias_level],
diff --git a/db/migrate/20180917034056_remove_superfluous_tables.rb b/db/migrate/20180917034056_remove_superfluous_tables.rb
index 5dfcb8ce95d..409f4878c18 100644
--- a/db/migrate/20180917034056_remove_superfluous_tables.rb
+++ b/db/migrate/20180917034056_remove_superfluous_tables.rb
@@ -3,7 +3,7 @@
require "migration/table_dropper"
class RemoveSuperfluousTables < ActiveRecord::Migration[5.2]
- DROPPED_TABLES ||= %i[category_featured_users versions topic_status_updates]
+ DROPPED_TABLES = %i[category_featured_users versions topic_status_updates]
def up
DROPPED_TABLES.each { |table| Migration::TableDropper.execute_drop(table) }
diff --git a/db/migrate/20190103065652_remove_uploaded_meta_id_from_category.rb b/db/migrate/20190103065652_remove_uploaded_meta_id_from_category.rb
index 24c4501dffd..2562072d927 100644
--- a/db/migrate/20190103065652_remove_uploaded_meta_id_from_category.rb
+++ b/db/migrate/20190103065652_remove_uploaded_meta_id_from_category.rb
@@ -3,7 +3,7 @@
require "migration/column_dropper"
class RemoveUploadedMetaIdFromCategory < ActiveRecord::Migration[5.2]
- DROPPED_COLUMNS ||= { categories: %i[uploaded_meta_id] }
+ DROPPED_COLUMNS = { categories: %i[uploaded_meta_id] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/migrate/20190312194528_drop_email_user_options_columns.rb b/db/migrate/20190312194528_drop_email_user_options_columns.rb
index 1367ba3871c..37cf3116200 100644
--- a/db/migrate/20190312194528_drop_email_user_options_columns.rb
+++ b/db/migrate/20190312194528_drop_email_user_options_columns.rb
@@ -3,7 +3,7 @@
require "migration/column_dropper"
class DropEmailUserOptionsColumns < ActiveRecord::Migration[5.2]
- DROPPED_COLUMNS ||= { user_options: %i[email_direct email_private_messages email_always] }
+ DROPPED_COLUMNS = { user_options: %i[email_direct email_private_messages email_always] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/migrate/20190716124050_remove_via_email_from_invite.rb b/db/migrate/20190716124050_remove_via_email_from_invite.rb
index f0d8b4779dd..93694ac2b15 100644
--- a/db/migrate/20190716124050_remove_via_email_from_invite.rb
+++ b/db/migrate/20190716124050_remove_via_email_from_invite.rb
@@ -3,7 +3,7 @@
require "migration/column_dropper"
class RemoveViaEmailFromInvite < ActiveRecord::Migration[5.2]
- DROPPED_COLUMNS ||= { invites: %i[via_email] }
+ DROPPED_COLUMNS = { invites: %i[via_email] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/migrate/20191107190330_remove_suppress_from_latest_from_category.rb b/db/migrate/20191107190330_remove_suppress_from_latest_from_category.rb
index fb836afa632..07ca0e59317 100644
--- a/db/migrate/20191107190330_remove_suppress_from_latest_from_category.rb
+++ b/db/migrate/20191107190330_remove_suppress_from_latest_from_category.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class RemoveSuppressFromLatestFromCategory < ActiveRecord::Migration[6.0]
- DROPPED_COLUMNS ||= { categories: %i[suppress_from_latest] }
+ DROPPED_COLUMNS = { categories: %i[suppress_from_latest] }
def up
ids = DB.query_single("SELECT id::text FROM categories WHERE suppress_from_latest = TRUE")
diff --git a/db/migrate/20191129144706_drop_unused_google_instagram_auth_tables.rb b/db/migrate/20191129144706_drop_unused_google_instagram_auth_tables.rb
index f6df758fc1a..32b3e660e12 100644
--- a/db/migrate/20191129144706_drop_unused_google_instagram_auth_tables.rb
+++ b/db/migrate/20191129144706_drop_unused_google_instagram_auth_tables.rb
@@ -3,7 +3,7 @@
require "migration/table_dropper"
class DropUnusedGoogleInstagramAuthTables < ActiveRecord::Migration[6.0]
- DROPPED_TABLES ||= %i[google_user_infos instagram_user_infos]
+ DROPPED_TABLES = %i[google_user_infos instagram_user_infos]
def up
DROPPED_TABLES.each { |table| Migration::TableDropper.execute_drop(table) }
diff --git a/db/migrate/20191219112000_remove_key_from_api_keys.rb b/db/migrate/20191219112000_remove_key_from_api_keys.rb
index c9dcb70f171..a53f199b084 100644
--- a/db/migrate/20191219112000_remove_key_from_api_keys.rb
+++ b/db/migrate/20191219112000_remove_key_from_api_keys.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
class RemoveKeyFromApiKeys < ActiveRecord::Migration[6.0]
- DROPPED_COLUMNS ||= { api_keys: %i[key] }
+ DROPPED_COLUMNS = { api_keys: %i[key] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/migrate/20200120131338_drop_unused_columns.rb b/db/migrate/20200120131338_drop_unused_columns.rb
index 9e0cd64c712..92ed7ce0c5d 100644
--- a/db/migrate/20200120131338_drop_unused_columns.rb
+++ b/db/migrate/20200120131338_drop_unused_columns.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropUnusedColumns < ActiveRecord::Migration[6.0]
- DROPPED_COLUMNS ||= {
+ DROPPED_COLUMNS = {
post_replies: %i[reply_id],
user_profiles: %i[card_background profile_background],
}
diff --git a/db/migrate/20200408121312_remove_key_from_user_api_key.rb b/db/migrate/20200408121312_remove_key_from_user_api_key.rb
index e2b0602fb8f..be6a9b78d4f 100644
--- a/db/migrate/20200408121312_remove_key_from_user_api_key.rb
+++ b/db/migrate/20200408121312_remove_key_from_user_api_key.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class RemoveKeyFromUserApiKey < ActiveRecord::Migration[6.0]
- DROPPED_COLUMNS ||= { user_api_keys: %i[key] }
+ DROPPED_COLUMNS = { user_api_keys: %i[key] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/migrate/20200415140830_drop_automatic_membership_retroactive_from_group.rb b/db/migrate/20200415140830_drop_automatic_membership_retroactive_from_group.rb
index 23a740aa27d..d6e0f793ead 100644
--- a/db/migrate/20200415140830_drop_automatic_membership_retroactive_from_group.rb
+++ b/db/migrate/20200415140830_drop_automatic_membership_retroactive_from_group.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropAutomaticMembershipRetroactiveFromGroup < ActiveRecord::Migration[6.0]
- DROPPED_COLUMNS ||= { groups: %i[automatic_membership_retroactive] }
+ DROPPED_COLUMNS = { groups: %i[automatic_membership_retroactive] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/migrate/20200513185052_drop_topic_reply_count.rb b/db/migrate/20200513185052_drop_topic_reply_count.rb
index 4b5a57f6f7d..a5eb8a36743 100644
--- a/db/migrate/20200513185052_drop_topic_reply_count.rb
+++ b/db/migrate/20200513185052_drop_topic_reply_count.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropTopicReplyCount < ActiveRecord::Migration[6.0]
- DROPPED_COLUMNS ||= { user_stats: %i[topic_reply_count] }
+ DROPPED_COLUMNS = { user_stats: %i[topic_reply_count] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/migrate/20200728004302_drop_path_whitelist_from_embeddable_hosts.rb b/db/migrate/20200728004302_drop_path_whitelist_from_embeddable_hosts.rb
index 1a85e38c8eb..c6cc57723d6 100644
--- a/db/migrate/20200728004302_drop_path_whitelist_from_embeddable_hosts.rb
+++ b/db/migrate/20200728004302_drop_path_whitelist_from_embeddable_hosts.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropPathWhitelistFromEmbeddableHosts < ActiveRecord::Migration[6.0]
- DROPPED_COLUMNS ||= { embeddable_hosts: %i[path_whitelist] }
+ DROPPED_COLUMNS = { embeddable_hosts: %i[path_whitelist] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/migrate/20210628035905_drop_duration_column_from_topic_timers.rb b/db/migrate/20210628035905_drop_duration_column_from_topic_timers.rb
index dc231c2ca1e..bc6fcad56cd 100644
--- a/db/migrate/20210628035905_drop_duration_column_from_topic_timers.rb
+++ b/db/migrate/20210628035905_drop_duration_column_from_topic_timers.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropDurationColumnFromTopicTimers < ActiveRecord::Migration[6.1]
- DROPPED_COLUMNS ||= { topic_timers: %i[duration] }
+ DROPPED_COLUMNS = { topic_timers: %i[duration] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/migrate/20210706091905_drop_disable_jump_reply_column_from_user_options.rb b/db/migrate/20210706091905_drop_disable_jump_reply_column_from_user_options.rb
index 59b105435b5..7e5d2ba08c9 100644
--- a/db/migrate/20210706091905_drop_disable_jump_reply_column_from_user_options.rb
+++ b/db/migrate/20210706091905_drop_disable_jump_reply_column_from_user_options.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropDisableJumpReplyColumnFromUserOptions < ActiveRecord::Migration[6.1]
- DROPPED_COLUMNS ||= { user_options: %i[disable_jump_reply] }
+ DROPPED_COLUMNS = { user_options: %i[disable_jump_reply] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/migrate/20210709053030_drop_uploads_verified.rb b/db/migrate/20210709053030_drop_uploads_verified.rb
index 5f999b35197..d007b921c37 100644
--- a/db/migrate/20210709053030_drop_uploads_verified.rb
+++ b/db/migrate/20210709053030_drop_uploads_verified.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropUploadsVerified < ActiveRecord::Migration[6.1]
- DROPPED_COLUMNS ||= { uploads: %i[verified] }
+ DROPPED_COLUMNS = { uploads: %i[verified] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/migrate/20211206160212_drop_token_from_email_tokens.rb b/db/migrate/20211206160212_drop_token_from_email_tokens.rb
index f42cd01ddcd..7274d446029 100644
--- a/db/migrate/20211206160212_drop_token_from_email_tokens.rb
+++ b/db/migrate/20211206160212_drop_token_from_email_tokens.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropTokenFromEmailTokens < ActiveRecord::Migration[6.1]
- DROPPED_COLUMNS ||= { email_tokens: %i[token] }
+ DROPPED_COLUMNS = { email_tokens: %i[token] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/migrate/20211224010204_drop_old_bookmark_columns.rb b/db/migrate/20211224010204_drop_old_bookmark_columns.rb
index 48793b0f2a0..44e13194ae3 100644
--- a/db/migrate/20211224010204_drop_old_bookmark_columns.rb
+++ b/db/migrate/20211224010204_drop_old_bookmark_columns.rb
@@ -3,7 +3,7 @@
require "migration/column_dropper"
class DropOldBookmarkColumns < ActiveRecord::Migration[6.1]
- DROPPED_COLUMNS ||= { bookmarks: %i[topic_id reminder_type] }
+ DROPPED_COLUMNS = { bookmarks: %i[topic_id reminder_type] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/migrate/20220401140745_drop_category_required_tag_group_columns.rb b/db/migrate/20220401140745_drop_category_required_tag_group_columns.rb
index b203db0d17c..9ebeeed7630 100644
--- a/db/migrate/20220401140745_drop_category_required_tag_group_columns.rb
+++ b/db/migrate/20220401140745_drop_category_required_tag_group_columns.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropCategoryRequiredTagGroupColumns < ActiveRecord::Migration[6.1]
- DROPPED_COLUMNS ||= { categories: %i[required_tag_group_id min_tags_from_required_group] }
+ DROPPED_COLUMNS = { categories: %i[required_tag_group_id min_tags_from_required_group] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/migrate/20220621164914_drop_flair_url_from_groups.rb b/db/migrate/20220621164914_drop_flair_url_from_groups.rb
index c66cfd036f3..11d23dd2e98 100644
--- a/db/migrate/20220621164914_drop_flair_url_from_groups.rb
+++ b/db/migrate/20220621164914_drop_flair_url_from_groups.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropFlairUrlFromGroups < ActiveRecord::Migration[7.0]
- DROPPED_COLUMNS ||= { groups: %i[flair_url] }
+ DROPPED_COLUMNS = { groups: %i[flair_url] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/migrate/20221108032233_drop_old_bookmark_columns_v2.rb b/db/migrate/20221108032233_drop_old_bookmark_columns_v2.rb
index 7860e1546f2..c76bd2f2b17 100644
--- a/db/migrate/20221108032233_drop_old_bookmark_columns_v2.rb
+++ b/db/migrate/20221108032233_drop_old_bookmark_columns_v2.rb
@@ -3,7 +3,7 @@
require "migration/column_dropper"
class DropOldBookmarkColumnsV2 < ActiveRecord::Migration[7.0]
- DROPPED_COLUMNS ||= { bookmarks: %i[post_id for_topic] }
+ DROPPED_COLUMNS = { bookmarks: %i[post_id for_topic] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/migrate/20230119024157_remove_topic_count_from_tags.rb b/db/migrate/20230119024157_remove_topic_count_from_tags.rb
index f51e3a1bcd5..2daadcecc00 100644
--- a/db/migrate/20230119024157_remove_topic_count_from_tags.rb
+++ b/db/migrate/20230119024157_remove_topic_count_from_tags.rb
@@ -3,7 +3,7 @@
require "migration/column_dropper"
class RemoveTopicCountFromTags < ActiveRecord::Migration[7.0]
- DROPPED_COLUMNS ||= { tags: %i[topic_count] }
+ DROPPED_COLUMNS = { tags: %i[topic_count] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/migrate/20230228105851_drop_badge_granted_title_column.rb b/db/migrate/20230228105851_drop_badge_granted_title_column.rb
index 2a646d850ee..bce21f71268 100644
--- a/db/migrate/20230228105851_drop_badge_granted_title_column.rb
+++ b/db/migrate/20230228105851_drop_badge_granted_title_column.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropBadgeGrantedTitleColumn < ActiveRecord::Migration[7.0]
- DROPPED_COLUMNS ||= { user_profiles: %i[badge_granted_title] }
+ DROPPED_COLUMNS = { user_profiles: %i[badge_granted_title] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/migrate/20230926165821_drop_post_uploads_table.rb b/db/migrate/20230926165821_drop_post_uploads_table.rb
index 6d580aadc37..31d34a937fe 100644
--- a/db/migrate/20230926165821_drop_post_uploads_table.rb
+++ b/db/migrate/20230926165821_drop_post_uploads_table.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropPostUploadsTable < ActiveRecord::Migration[7.0]
- DROPPED_TABLES ||= %i[post_uploads]
+ DROPPED_TABLES = %i[post_uploads]
def up
DROPPED_TABLES.each { |table| Migration::TableDropper.execute_drop(table) }
diff --git a/db/post_migrate/20240202052058_drop_badge_image_column.rb b/db/post_migrate/20240202052058_drop_badge_image_column.rb
index 20cc8bbedbb..8da554aeac5 100644
--- a/db/post_migrate/20240202052058_drop_badge_image_column.rb
+++ b/db/post_migrate/20240202052058_drop_badge_image_column.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropBadgeImageColumn < ActiveRecord::Migration[7.0]
- DROPPED_COLUMNS ||= { badges: %i[image] }
+ DROPPED_COLUMNS = { badges: %i[image] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/post_migrate/20240212034010_drop_deprecated_columns.rb b/db/post_migrate/20240212034010_drop_deprecated_columns.rb
index 0899da200f2..7eecd628351 100644
--- a/db/post_migrate/20240212034010_drop_deprecated_columns.rb
+++ b/db/post_migrate/20240212034010_drop_deprecated_columns.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropDeprecatedColumns < ActiveRecord::Migration[7.0]
- DROPPED_COLUMNS ||= {
+ DROPPED_COLUMNS = {
categories: %i[suppress_from_latest required_tag_group_id min_tags_from_required_group],
directory_columns: %i[automatic],
email_tokens: %i[token],
diff --git a/db/post_migrate/20240612073116_swap_field_type_with_field_type_enum_on_user_fields.rb b/db/post_migrate/20240612073116_swap_field_type_with_field_type_enum_on_user_fields.rb
index 8b98bc48c08..0169bf033e0 100644
--- a/db/post_migrate/20240612073116_swap_field_type_with_field_type_enum_on_user_fields.rb
+++ b/db/post_migrate/20240612073116_swap_field_type_with_field_type_enum_on_user_fields.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class SwapFieldTypeWithFieldTypeEnumOnUserFields < ActiveRecord::Migration[7.0]
- # DROPPED_COLUMNS ||= { user_fields: %i[field_type] }
+ # DROPPED_COLUMNS = { user_fields: %i[field_type] }
# def up
# # WARNING: Swapping in a column of a different type in a post-migration will break the AR
diff --git a/db/post_migrate/20240711123755_drop_compiled_js_from_translation_overrides.rb b/db/post_migrate/20240711123755_drop_compiled_js_from_translation_overrides.rb
index 1476e63cf35..2cd3eb682d1 100644
--- a/db/post_migrate/20240711123755_drop_compiled_js_from_translation_overrides.rb
+++ b/db/post_migrate/20240711123755_drop_compiled_js_from_translation_overrides.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropCompiledJsFromTranslationOverrides < ActiveRecord::Migration[7.1]
- DROPPED_COLUMNS ||= { translation_overrides: %i[compiled_js] }
+ DROPPED_COLUMNS = { translation_overrides: %i[compiled_js] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/post_migrate/20240714231516_drop_custom_type_from_flags.rb b/db/post_migrate/20240714231516_drop_custom_type_from_flags.rb
index c2075159f10..3fd3c32afa8 100644
--- a/db/post_migrate/20240714231516_drop_custom_type_from_flags.rb
+++ b/db/post_migrate/20240714231516_drop_custom_type_from_flags.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropCustomTypeFromFlags < ActiveRecord::Migration[7.0]
- DROPPED_COLUMNS ||= { flags: %i[custom_type] }
+ DROPPED_COLUMNS = { flags: %i[custom_type] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/db/post_migrate/20240717053710_drop_groups_smtp_ssl.rb b/db/post_migrate/20240717053710_drop_groups_smtp_ssl.rb
index 3c4f2faf830..32f6b14ffd9 100644
--- a/db/post_migrate/20240717053710_drop_groups_smtp_ssl.rb
+++ b/db/post_migrate/20240717053710_drop_groups_smtp_ssl.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropGroupsSmtpSsl < ActiveRecord::Migration[7.1]
- DROPPED_COLUMNS ||= { groups: %i[smtp_ssl] }
+ DROPPED_COLUMNS = { groups: %i[smtp_ssl] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
diff --git a/lib/auth/default_current_user_provider.rb b/lib/auth/default_current_user_provider.rb
index 4a23f0b1c48..b8b73608dc2 100644
--- a/lib/auth/default_current_user_provider.rb
+++ b/lib/auth/default_current_user_provider.rb
@@ -23,28 +23,28 @@ require_relative "../route_matcher"
# We'll drop support for v0 after Discourse 2.9 is released.
class Auth::DefaultCurrentUserProvider
- CURRENT_USER_KEY ||= "_DISCOURSE_CURRENT_USER"
- USER_TOKEN_KEY ||= "_DISCOURSE_USER_TOKEN"
- API_KEY ||= "api_key"
- API_USERNAME ||= "api_username"
- HEADER_API_KEY ||= "HTTP_API_KEY"
- HEADER_API_USERNAME ||= "HTTP_API_USERNAME"
- HEADER_API_USER_EXTERNAL_ID ||= "HTTP_API_USER_EXTERNAL_ID"
- HEADER_API_USER_ID ||= "HTTP_API_USER_ID"
- PARAMETER_USER_API_KEY ||= "user_api_key"
- USER_API_KEY ||= "HTTP_USER_API_KEY"
- USER_API_CLIENT_ID ||= "HTTP_USER_API_CLIENT_ID"
- API_KEY_ENV ||= "_DISCOURSE_API"
- USER_API_KEY_ENV ||= "_DISCOURSE_USER_API"
- TOKEN_COOKIE ||= ENV["DISCOURSE_TOKEN_COOKIE"] || "_t"
- PATH_INFO ||= "PATH_INFO"
- COOKIE_ATTEMPTS_PER_MIN ||= 10
- BAD_TOKEN ||= "_DISCOURSE_BAD_TOKEN"
+ CURRENT_USER_KEY = "_DISCOURSE_CURRENT_USER"
+ USER_TOKEN_KEY = "_DISCOURSE_USER_TOKEN"
+ API_KEY = "api_key"
+ API_USERNAME = "api_username"
+ HEADER_API_KEY = "HTTP_API_KEY"
+ HEADER_API_USERNAME = "HTTP_API_USERNAME"
+ HEADER_API_USER_EXTERNAL_ID = "HTTP_API_USER_EXTERNAL_ID"
+ HEADER_API_USER_ID = "HTTP_API_USER_ID"
+ PARAMETER_USER_API_KEY = "user_api_key"
+ USER_API_KEY = "HTTP_USER_API_KEY"
+ USER_API_CLIENT_ID = "HTTP_USER_API_CLIENT_ID"
+ API_KEY_ENV = "_DISCOURSE_API"
+ USER_API_KEY_ENV = "_DISCOURSE_USER_API"
+ TOKEN_COOKIE = ENV["DISCOURSE_TOKEN_COOKIE"] || "_t"
+ PATH_INFO = "PATH_INFO"
+ COOKIE_ATTEMPTS_PER_MIN = 10
+ BAD_TOKEN = "_DISCOURSE_BAD_TOKEN"
DECRYPTED_AUTH_COOKIE = "_DISCOURSE_DECRYPTED_AUTH_COOKIE"
TOKEN_SIZE = 32
- PARAMETER_API_PATTERNS ||= [
+ PARAMETER_API_PATTERNS = [
RouteMatcher.new(
methods: :get,
actions: [
diff --git a/lib/auth/facebook_authenticator.rb b/lib/auth/facebook_authenticator.rb
index 18924c5fc00..8d7abf55e8b 100644
--- a/lib/auth/facebook_authenticator.rb
+++ b/lib/auth/facebook_authenticator.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class Auth::FacebookAuthenticator < Auth::ManagedAuthenticator
- AVATAR_SIZE ||= 480
+ AVATAR_SIZE = 480
def name
"facebook"
diff --git a/lib/auth/google_oauth2_authenticator.rb b/lib/auth/google_oauth2_authenticator.rb
index 3e7c4c4afb6..ac331cd3d84 100644
--- a/lib/auth/google_oauth2_authenticator.rb
+++ b/lib/auth/google_oauth2_authenticator.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
class Auth::GoogleOAuth2Authenticator < Auth::ManagedAuthenticator
- GROUPS_SCOPE ||= "https://www.googleapis.com/auth/admin.directory.group.readonly"
- GROUPS_DOMAIN ||= "admin.googleapis.com"
- GROUPS_PATH ||= "/admin/directory/v1/groups"
- OAUTH2_BASE_URL ||= "https://oauth2.googleapis.com"
+ GROUPS_SCOPE = "https://www.googleapis.com/auth/admin.directory.group.readonly"
+ GROUPS_DOMAIN = "admin.googleapis.com"
+ GROUPS_PATH = "/admin/directory/v1/groups"
+ OAUTH2_BASE_URL = "https://oauth2.googleapis.com"
def name
"google_oauth2"
diff --git a/lib/backup_restore/s3_backup_store.rb b/lib/backup_restore/s3_backup_store.rb
index 492ccaf2344..430d65c5e6a 100644
--- a/lib/backup_restore/s3_backup_store.rb
+++ b/lib/backup_restore/s3_backup_store.rb
@@ -2,7 +2,7 @@
module BackupRestore
class S3BackupStore < BackupStore
- UPLOAD_URL_EXPIRES_AFTER_SECONDS ||= 6.hours.to_i
+ UPLOAD_URL_EXPIRES_AFTER_SECONDS = 6.hours.to_i
delegate :abort_multipart,
:presign_multipart_part,
diff --git a/lib/db_helper.rb b/lib/db_helper.rb
index db9a9a0df84..3813e6747c4 100644
--- a/lib/db_helper.rb
+++ b/lib/db_helper.rb
@@ -3,7 +3,7 @@
require "migration/base_dropper"
class DbHelper
- REMAP_SQL ||= <<~SQL
+ REMAP_SQL = <<~SQL
SELECT table_name::text, column_name::text, character_maximum_length
FROM information_schema.columns
WHERE table_schema = 'public'
@@ -12,13 +12,13 @@ class DbHelper
ORDER BY table_name, column_name
SQL
- TRIGGERS_SQL ||= <<~SQL
+ TRIGGERS_SQL = <<~SQL
SELECT trigger_name::text
FROM information_schema.triggers
WHERE trigger_name LIKE '%_readonly'
SQL
- TRUNCATABLE_COLUMNS ||= ["topic_links.url"]
+ TRUNCATABLE_COLUMNS = ["topic_links.url"]
def self.remap(
from,
diff --git a/lib/demon/email_sync.rb b/lib/demon/email_sync.rb
index 736f3adfc48..1d6b3c56a09 100644
--- a/lib/demon/email_sync.rb
+++ b/lib/demon/email_sync.rb
@@ -3,8 +3,8 @@
require "demon/base"
class Demon::EmailSync < ::Demon::Base
- HEARTBEAT_KEY ||= "email_sync_heartbeat"
- HEARTBEAT_INTERVAL ||= 60.seconds
+ HEARTBEAT_KEY = "email_sync_heartbeat"
+ HEARTBEAT_INTERVAL = 60.seconds
def self.prefix
"email_sync"
diff --git a/lib/discourse.rb b/lib/discourse.rb
index 68119a94571..af9e3620d91 100644
--- a/lib/discourse.rb
+++ b/lib/discourse.rb
@@ -7,15 +7,15 @@ require "version"
require "git_utils"
module Discourse
- DB_POST_MIGRATE_PATH ||= "db/post_migrate"
- REQUESTED_HOSTNAME ||= "REQUESTED_HOSTNAME"
+ DB_POST_MIGRATE_PATH = "db/post_migrate"
+ REQUESTED_HOSTNAME = "REQUESTED_HOSTNAME"
MAX_METADATA_FILE_SIZE = 64.kilobytes
class Utils
- URI_REGEXP ||= URI.regexp(%w[http https])
+ URI_REGEXP = URI.regexp(%w[http https])
# TODO: Remove this once we drop support for Ruby 2.
- EMPTY_KEYWORDS ||= {}
+ EMPTY_KEYWORDS = {}
# Usage:
# Discourse::Utils.execute_command("pwd", chdir: 'mydirectory')
@@ -658,17 +658,17 @@ module Discourse
LAST_POSTGRES_READONLY_KEY = "postgres:last_readonly"
- READONLY_MODE_KEY_TTL ||= 60
- READONLY_MODE_KEY ||= "readonly_mode"
- PG_READONLY_MODE_KEY ||= "readonly_mode:postgres"
- PG_READONLY_MODE_KEY_TTL ||= 300
- USER_READONLY_MODE_KEY ||= "readonly_mode:user"
- PG_FORCE_READONLY_MODE_KEY ||= "readonly_mode:postgres_force"
+ READONLY_MODE_KEY_TTL = 60
+ READONLY_MODE_KEY = "readonly_mode"
+ PG_READONLY_MODE_KEY = "readonly_mode:postgres"
+ PG_READONLY_MODE_KEY_TTL = 300
+ USER_READONLY_MODE_KEY = "readonly_mode:user"
+ PG_FORCE_READONLY_MODE_KEY = "readonly_mode:postgres_force"
# Pseudo readonly mode, where staff can still write
- STAFF_WRITES_ONLY_MODE_KEY ||= "readonly_mode:staff_writes_only"
+ STAFF_WRITES_ONLY_MODE_KEY = "readonly_mode:staff_writes_only"
- READONLY_KEYS ||= [
+ READONLY_KEYS = [
READONLY_MODE_KEY,
PG_READONLY_MODE_KEY,
USER_READONLY_MODE_KEY,
diff --git a/lib/discourse_tagging.rb b/lib/discourse_tagging.rb
index 35277fb3054..50101179d6a 100644
--- a/lib/discourse_tagging.rb
+++ b/lib/discourse_tagging.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
module DiscourseTagging
- TAGS_FIELD_NAME ||= "tags"
- TAGS_FILTER_REGEXP ||= /[\/\?#\[\]@!\$&'\(\)\*\+,;=\.%\\`^\s|\{\}"<>]+/ # /?#[]@!$&'()*+,;=.%\`^|{}"<>
- TAGS_STAFF_CACHE_KEY ||= "staff_tag_names"
+ TAGS_FIELD_NAME = "tags"
+ TAGS_FILTER_REGEXP = /[\/\?#\[\]@!\$&'\(\)\*\+,;=\.%\\`^\s|\{\}"<>]+/ # /?#[]@!$&'()*+,;=.%\`^|{}"<>
+ TAGS_STAFF_CACHE_KEY = "staff_tag_names"
- TAG_GROUP_TAG_IDS_SQL ||= <<-SQL
+ TAG_GROUP_TAG_IDS_SQL = <<-SQL
SELECT tag_id
FROM tag_group_memberships tgm
INNER JOIN tag_groups tg
@@ -370,7 +370,7 @@ module DiscourseTagging
tags_by_group_map.select { |_, group_tags| group_tags.size > 1 }
end
- TAG_GROUP_RESTRICTIONS_SQL ||= <<~SQL
+ TAG_GROUP_RESTRICTIONS_SQL = <<~SQL
tag_group_restrictions AS (
SELECT t.id as tag_id, tgm.id as tgm_id, tg.id as tag_group_id, tg.parent_tag_id as parent_tag_id,
tg.one_per_topic as one_per_topic
@@ -380,7 +380,7 @@ module DiscourseTagging
)
SQL
- CATEGORY_RESTRICTIONS_SQL ||= <<~SQL
+ CATEGORY_RESTRICTIONS_SQL = <<~SQL
category_restrictions AS (
SELECT t.id as tag_id, ct.id as ct_id, ct.category_id as category_id, NULL AS category_tag_group_id
FROM tags t
@@ -395,7 +395,7 @@ module DiscourseTagging
)
SQL
- PERMITTED_TAGS_SQL ||= <<~SQL
+ PERMITTED_TAGS_SQL = <<~SQL
permitted_tag_groups AS (
SELECT tg.id as tag_group_id, tgp.group_id as group_id, tgp.permission_type as permission_type
FROM tags t
diff --git a/lib/email/receiver.rb b/lib/email/receiver.rb
index 7de0b311538..645722c8324 100644
--- a/lib/email/receiver.rb
+++ b/lib/email/receiver.rb
@@ -95,7 +95,7 @@ module Email
attr_reader :mail
attr_reader :message_id
- COMMON_ENCODINGS ||= [-"utf-8", -"windows-1252", -"iso-8859-1"]
+ COMMON_ENCODINGS = [-"utf-8", -"windows-1252", -"iso-8859-1"]
def self.formats
@formats ||= Enum.new(plaintext: 1, markdown: 2)
@@ -527,7 +527,7 @@ module Email
[EmailReplyTrimmer.trim(markdown), elided_markdown]
end
- HTML_EXTRACTERS ||= [
+ HTML_EXTRACTERS = [
[:gmail, /class="gmail_(signature|extra)/],
[:outlook, /id="(divRplyFwdMsg|Signature)"/],
[:word, /class="WordSection1"/],
diff --git a/lib/file_store/base_store.rb b/lib/file_store/base_store.rb
index 99e95422cb5..6fea6a402c6 100644
--- a/lib/file_store/base_store.rb
+++ b/lib/file_store/base_store.rb
@@ -5,9 +5,9 @@ module FileStore
end
class BaseStore
- UPLOAD_PATH_REGEX ||= %r{/(original/\d+X/.*)}
- OPTIMIZED_IMAGE_PATH_REGEX ||= %r{/(optimized/\d+X/.*)}
- TEMPORARY_UPLOAD_PREFIX ||= "temp/"
+ UPLOAD_PATH_REGEX = %r{/(original/\d+X/.*)}
+ OPTIMIZED_IMAGE_PATH_REGEX = %r{/(optimized/\d+X/.*)}
+ TEMPORARY_UPLOAD_PREFIX = "temp/"
def store_upload(file, upload, content_type = nil)
upload.url = nil
diff --git a/lib/file_store/s3_store.rb b/lib/file_store/s3_store.rb
index 3c07e462034..f332dc753c5 100644
--- a/lib/file_store/s3_store.rb
+++ b/lib/file_store/s3_store.rb
@@ -8,7 +8,7 @@ require "file_helper"
module FileStore
class S3Store < BaseStore
- TOMBSTONE_PREFIX ||= "tombstone/"
+ TOMBSTONE_PREFIX = "tombstone/"
delegate :abort_multipart,
:presign_multipart_part,
diff --git a/lib/file_store/to_s3_migration.rb b/lib/file_store/to_s3_migration.rb
index 75b5be278ac..dacfa20b785 100644
--- a/lib/file_store/to_s3_migration.rb
+++ b/lib/file_store/to_s3_migration.rb
@@ -6,8 +6,8 @@ module FileStore
ToS3MigrationError = Class.new(RuntimeError)
class ToS3Migration
- MISSING_UPLOADS_RAKE_TASK_NAME ||= "posts:missing_uploads"
- UPLOAD_CONCURRENCY ||= 20
+ MISSING_UPLOADS_RAKE_TASK_NAME = "posts:missing_uploads"
+ UPLOAD_CONCURRENCY = 20
def initialize(s3_options:, dry_run: false, migrate_to_multisite: false)
@s3_bucket = s3_options[:bucket]
diff --git a/lib/html_to_markdown.rb b/lib/html_to_markdown.rb
index 7ba8bc35bcd..add51e7e1b5 100644
--- a/lib/html_to_markdown.rb
+++ b/lib/html_to_markdown.rb
@@ -157,7 +157,7 @@ class HtmlToMarkdown
send(visitor, node) if respond_to?(visitor, true)
end
- ALLOWED_IMG_SRCS ||= %w[http:// https:// www.]
+ ALLOWED_IMG_SRCS = %w[http:// https:// www.]
def allowed_hrefs
@allowed_hrefs ||=
@@ -195,7 +195,7 @@ class HtmlToMarkdown
end
end
- ALLOWED ||= %w[kbd del ins small big sub sup dl dd dt mark]
+ ALLOWED = %w[kbd del ins small big sub sup dl dd dt mark]
ALLOWED.each do |tag|
define_method("visit_#{tag}") do |node|
"<#{tag}>#{traverse(node, within_html_block: true)}</#{tag}>"
@@ -210,7 +210,7 @@ class HtmlToMarkdown
"\n\n#{text}\n\n"
end
- BLOCKS ||= %w[div tr]
+ BLOCKS = %w[div tr]
BLOCKS.each do |tag|
define_method("visit_#{tag}") do |node|
prefix = block?(node.previous_element) ? "" : "\n"
@@ -222,7 +222,7 @@ class HtmlToMarkdown
"\n\n#{traverse(node)}\n\n"
end
- TRAVERSABLES ||= %w[aside font span thead tbody tfoot u center]
+ TRAVERSABLES = %w[aside font span thead tbody tfoot u center]
TRAVERSABLES.each { |tag| define_method("visit_#{tag}") { |node| traverse(node) } }
def visit_tt(node)
@@ -290,7 +290,7 @@ class HtmlToMarkdown
@within_html_block ? "<tr>\n#{text}</tr>\n" : text
end
- TABLE_CELLS ||= %w[th td]
+ TABLE_CELLS = %w[th td]
TABLE_CELLS.each do |tag|
define_method("visit_#{tag}") do |node|
text = traverse(node)
@@ -306,7 +306,7 @@ class HtmlToMarkdown
end
end
- LISTS ||= %w[ul ol]
+ LISTS = %w[ul ol]
LISTS.each do |tag|
define_method("visit_#{tag}") do |node|
prefix = block?(node.previous_element) ? "" : "\n"
@@ -330,7 +330,7 @@ class HtmlToMarkdown
"#{marker}#{text}#{suffix}"
end
- EMPHASES ||= %w[i em]
+ EMPHASES = %w[i em]
EMPHASES.each do |tag|
define_method("visit_#{tag}") do |node|
text = traverse(node)
@@ -347,7 +347,7 @@ class HtmlToMarkdown
end
end
- STRONGS ||= %w[b strong]
+ STRONGS = %w[b strong]
STRONGS.each do |tag|
define_method("visit_#{tag}") do |node|
text = traverse(node)
@@ -364,7 +364,7 @@ class HtmlToMarkdown
end
end
- STRIKES ||= %w[s strike]
+ STRIKES = %w[s strike]
STRIKES.each do |tag|
define_method("visit_#{tag}") do |node|
text = traverse(node)
diff --git a/lib/migration/base_dropper.rb b/lib/migration/base_dropper.rb
index abf7a39a734..6e43edcb9f0 100644
--- a/lib/migration/base_dropper.rb
+++ b/lib/migration/base_dropper.rb
@@ -2,7 +2,7 @@
module Migration
class BaseDropper
- FUNCTION_SCHEMA_NAME ||= "discourse_functions"
+ FUNCTION_SCHEMA_NAME = "discourse_functions"
def self.create_readonly_function(table_name, column_name = nil)
DB.exec <<~SQL
diff --git a/lib/onebox/engine/youtube_onebox.rb b/lib/onebox/engine/youtube_onebox.rb
index 0b6839d012c..8aa9a514802 100644
--- a/lib/onebox/engine/youtube_onebox.rb
+++ b/lib/onebox/engine/youtube_onebox.rb
@@ -10,8 +10,8 @@ module Onebox
requires_iframe_origins "https://www.youtube.com"
always_https
- WIDTH ||= 480
- HEIGHT ||= 360
+ WIDTH = 480
+ HEIGHT = 360
def parse_embed_response
return unless video_id
diff --git a/lib/onebox/helpers.rb b/lib/onebox/helpers.rb
index 8817781f0a5..f80cca5fba3 100644
--- a/lib/onebox/helpers.rb
+++ b/lib/onebox/helpers.rb
@@ -7,7 +7,7 @@ module Onebox
class DownloadTooLarge < StandardError
end
- IGNORE_CANONICAL_DOMAINS ||= %w[www.instagram.com medium.com youtube.com]
+ IGNORE_CANONICAL_DOMAINS = %w[www.instagram.com medium.com youtube.com]
def self.clean(html)
html.gsub(/<[^>]+>/, " ").gsub(/\n/, "")
diff --git a/lib/onebox/preview.rb b/lib/onebox/preview.rb
index 1e387aacd5c..bd0526275dd 100644
--- a/lib/onebox/preview.rb
+++ b/lib/onebox/preview.rb
@@ -5,7 +5,7 @@ module Onebox
# see https://bugs.ruby-lang.org/issues/14688
client_exception =
defined?(Net::HTTPClientException) ? Net::HTTPClientException : Net::HTTPServerException
- WEB_EXCEPTIONS ||= [
+ WEB_EXCEPTIONS = [
client_exception,
OpenURI::HTTPError,
Timeout::Error,
diff --git a/lib/onebox/sanitize_config.rb b/lib/onebox/sanitize_config.rb
index bec61963db1..6753403998d 100644
--- a/lib/onebox/sanitize_config.rb
+++ b/lib/onebox/sanitize_config.rb
@@ -107,7 +107,7 @@ module Onebox
),
)
- DISCOURSE_ONEBOX ||=
+ DISCOURSE_ONEBOX =
Sanitize::Config.freeze_config(
Sanitize::Config.merge(
ONEBOX,
diff --git a/lib/plain_text_to_markdown.rb b/lib/plain_text_to_markdown.rb
index d914cd867e5..ec332f69292 100644
--- a/lib/plain_text_to_markdown.rb
+++ b/lib/plain_text_to_markdown.rb
@@ -153,9 +153,9 @@ class PlainTextToMarkdown
converted_text
end
- URL_REGEX ||= URI.regexp(%w[http https ftp mailto])
- BEFORE ||= Regexp.escape(%Q|([<«"“'‘|)
- AFTER ||= Regexp.escape(%Q|)]>»"”'’|)
+ URL_REGEX = URI.regexp(%w[http https ftp mailto])
+ BEFORE = Regexp.escape(%Q|([<«"“'‘|)
+ AFTER = Regexp.escape(%Q|)]>»"”'’|)
def replace_duplicate_links(text)
urls = Set.new
diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rb
index 4f82bbfa187..df16158651a 100644
--- a/lib/plugin/instance.rb
+++ b/lib/plugin/instance.rb
@@ -6,7 +6,8 @@ require "plugin/metadata"
require "auth"
class Plugin::CustomEmoji
- CACHE_KEY ||= "plugin-emoji"
+ CACHE_KEY = "plugin-emoji"
+
def self.cache_key
@@cache_key ||= CACHE_KEY
end
diff --git a/lib/plugin/metadata.rb b/lib/plugin/metadata.rb
index 4f6884d8b30..8c26a26b1fc 100644
--- a/lib/plugin/metadata.rb
+++ b/lib/plugin/metadata.rb
@@ -5,7 +5,7 @@ module Plugin
end
class Plugin::Metadata
- OFFICIAL_PLUGINS ||=
+ OFFICIAL_PLUGINS =
Set.new(
%w[
discourse-adplugin
@@ -97,10 +97,10 @@ class Plugin::Metadata
],
)
- FIELDS ||= %i[name about version authors contact_emails url required_version meta_topic_id label]
+ FIELDS = %i[name about version authors contact_emails url required_version meta_topic_id label]
attr_accessor(*FIELDS)
- MAX_FIELD_LENGTHS ||= {
+ MAX_FIELD_LENGTHS = {
name: 75,
about: 350,
authors: 200,
diff --git a/lib/presence_channel.rb b/lib/presence_channel.rb
index be07ddca376..128ec24ca07 100644
--- a/lib/presence_channel.rb
+++ b/lib/presence_channel.rb
@@ -42,7 +42,7 @@ class PresenceChannel
# allowed_group_ids: array of group_ids that can view, and become present in, the channel (default [])
# count_only: boolean. If true, user identities are never revealed to clients. (default [])
class Config
- NOT_FOUND ||= "notfound"
+ NOT_FOUND = "notfound"
attr_accessor :public, :allowed_user_ids, :allowed_group_ids, :count_only, :timeout
@@ -76,11 +76,11 @@ class PresenceChannel
end
end
- DEFAULT_TIMEOUT ||= 60
- CONFIG_CACHE_SECONDS ||= 10
- GC_SECONDS ||= 24.hours.to_i
- MUTEX_TIMEOUT_SECONDS ||= 10
- MUTEX_LOCKED_ERROR ||= "PresenceChannel mutex is locked"
+ DEFAULT_TIMEOUT = 60
+ CONFIG_CACHE_SECONDS = 10
+ GC_SECONDS = 24.hours.to_i
+ MUTEX_TIMEOUT_SECONDS = 10
+ MUTEX_LOCKED_ERROR = "PresenceChannel mutex is locked"
@@configuration_blocks ||= {}
@@ -469,7 +469,7 @@ class PresenceChannel
end
LUA
- LUA_SCRIPTS ||= {}
+ LUA_SCRIPTS = {}
LUA_SCRIPTS[:present] = DiscourseRedis::EvalHelper.new <<~LUA
#{COMMON_PRESENT_LEAVE_LUA}
diff --git a/lib/route_matcher.rb b/lib/route_matcher.rb
index b8ea48a492b..f2243f8c1cb 100644
--- a/lib/route_matcher.rb
+++ b/lib/route_matcher.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class RouteMatcher
- PATH_PARAMETERS ||= "_DISCOURSE_REQUEST_PATH_PARAMETERS"
+ PATH_PARAMETERS = "_DISCOURSE_REQUEST_PATH_PARAMETERS"
attr_reader :actions, :params, :methods, :aliases, :formats, :allowed_param_values
diff --git a/lib/scheduler/defer.rb b/lib/scheduler/defer.rb
index feb3b1ce3da..995403093a0 100644
--- a/lib/scheduler/defer.rb
+++ b/lib/scheduler/defer.rb
@@ -3,8 +3,8 @@ require "weakref"
module Scheduler
module Deferrable
- DEFAULT_TIMEOUT ||= 90
- STATS_CACHE_SIZE ||= 100
+ DEFAULT_TIMEOUT = 90
+ STATS_CACHE_SIZE = 100
def initialize
@async = !Rails.env.test?
diff --git a/lib/search.rb b/lib/search.rb
index 05cd3653607..d8557cc3b85 100644
--- a/lib/search.rb
+++ b/lib/search.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class Search
- DIACRITICS ||= /([\u0300-\u036f]|[\u1AB0-\u1AFF]|[\u1DC0-\u1DFF]|[\u20D0-\u20FF])/
+ DIACRITICS = /([\u0300-\u036f]|[\u1AB0-\u1AFF]|[\u1DC0-\u1DFF]|[\u20D0-\u20FF])/
HIGHLIGHT_CSS_CLASS = "search-highlight"
cattr_accessor :preloaded_topic_custom_fields
diff --git a/lib/site_setting_extension.rb b/lib/site_setting_extension.rb
index 5971d9cac4d..95b3df4b798 100644
--- a/lib/site_setting_extension.rb
+++ b/lib/site_setting_extension.rb
@@ -438,7 +438,7 @@ module SiteSettingExtension
refresh_settings.include?(name.to_sym)
end
- HOSTNAME_SETTINGS ||= %w[
+ HOSTNAME_SETTINGS = %w[
disabled_image_download_domains
blocked_onebox_domains
exclude_rel_nofollow_domains
diff --git a/lib/stylesheet/importer.rb b/lib/stylesheet/importer.rb
index daab2cd31a4..6e390a828e3 100644
--- a/lib/stylesheet/importer.rb
+++ b/lib/stylesheet/importer.rb
@@ -6,7 +6,7 @@ module Stylesheet
class Importer
include GlobalPath
- THEME_TARGETS ||= %w[embedded_theme mobile_theme desktop_theme]
+ THEME_TARGETS = %w[embedded_theme mobile_theme desktop_theme]
def self.plugin_assets
@plugin_assets ||= {}
diff --git a/lib/stylesheet/manager.rb b/lib/stylesheet/manager.rb
index 04b1de3b696..1ab10790269 100644
--- a/lib/stylesheet/manager.rb
+++ b/lib/stylesheet/manager.rb
@@ -12,9 +12,9 @@ class Stylesheet::Manager
CACHE_PATH = "tmp/stylesheet-cache"
private_constant :CACHE_PATH
- MANIFEST_DIR ||= "#{Rails.root}/tmp/cache/assets/#{Rails.env}"
- THEME_REGEX ||= /_theme\z/
- COLOR_SCHEME_STYLESHEET ||= "color_definitions"
+ MANIFEST_DIR = "#{Rails.root}/tmp/cache/assets/#{Rails.env}"
+ THEME_REGEX = /_theme\z/
+ COLOR_SCHEME_STYLESHEET = "color_definitions"
@@lock = Mutex.new
diff --git a/lib/text_sentinel.rb b/lib/text_sentinel.rb
index 9ae59fd8c87..2c806733dbf 100644
--- a/lib/text_sentinel.rb
+++ b/lib/text_sentinel.rb
@@ -3,7 +3,7 @@
class TextSentinel
attr_accessor :text
- ENTROPY_SCALE ||= 0.7
+ ENTROPY_SCALE = 0.7
def initialize(text, opts = nil)
@opts = opts || {}
diff --git a/lib/upload_creator.rb b/lib/upload_creator.rb
index 3a70dfca6e9..0e823cfc653 100644
--- a/lib/upload_creator.rb
+++ b/lib/upload_creator.rb
@@ -3,9 +3,9 @@
require "fastimage"
class UploadCreator
- TYPES_TO_CROP ||= %w[avatar card_background custom_emoji profile_background].each(&:freeze)
+ TYPES_TO_CROP = %w[avatar card_background custom_emoji profile_background].each(&:freeze)
- ALLOWED_SVG_ELEMENTS ||= %w[
+ ALLOWED_SVG_ELEMENTS = %w[
circle
clipPath
defs
@@ -312,7 +312,7 @@ class UploadCreator
end
end
- MIN_PIXELS_TO_CONVERT_TO_JPEG ||= 1280 * 720
+ MIN_PIXELS_TO_CONVERT_TO_JPEG = 1280 * 720
def convert_png_to_jpeg?
return false unless @image_info.type == :png
diff --git a/lib/version.rb b/lib/version.rb
index a5ef84439af..3d0a1bb9629 100644
--- a/lib/version.rb
+++ b/lib/version.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
module Discourse
- VERSION_REGEXP ||= /\A\d+\.\d+\.\d+(\.beta\d+)?\z/
- VERSION_COMPATIBILITY_FILENAME ||= ".discourse-compatibility"
+ VERSION_REGEXP = /\A\d+\.\d+\.\d+(\.beta\d+)?\z/
+ VERSION_COMPATIBILITY_FILENAME = ".discourse-compatibility"
# work around reloader
unless defined?(::Discourse::VERSION)
module VERSION #:nodoc:
diff --git a/plugins/chat/app/controllers/chat/api/channels_controller.rb b/plugins/chat/app/controllers/chat/api/channels_controller.rb
index 56dc148ec8d..69a0058bf1b 100644
--- a/plugins/chat/app/controllers/chat/api/channels_controller.rb
+++ b/plugins/chat/app/controllers/chat/api/channels_controller.rb
@@ -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)
diff --git a/plugins/chat/db/migrate/20220504080457_drop_old_chat_message_post_id_action_code_columns.rb b/plugins/chat/db/migrate/20220504080457_drop_old_chat_message_post_id_action_code_columns.rb
index 6ca1c406b8c..f7ca20bd213 100644
--- a/plugins/chat/db/migrate/20220504080457_drop_old_chat_message_post_id_action_code_columns.rb
+++ b/plugins/chat/db/migrate/20220504080457_drop_old_chat_message_post_id_action_code_columns.rb
@@ -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) }
diff --git a/plugins/chat/db/migrate/20220531105951_drop_user_chat_channel_last_reads.rb b/plugins/chat/db/migrate/20220531105951_drop_user_chat_channel_last_reads.rb
index b746266d85f..5bf3325dcc4 100644
--- a/plugins/chat/db/migrate/20220531105951_drop_user_chat_channel_last_reads.rb
+++ b/plugins/chat/db/migrate/20220531105951_drop_user_chat_channel_last_reads.rb
@@ -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) }
diff --git a/plugins/chat/db/migrate/20220630074200_drop_chat_isolated_from_user_options.rb b/plugins/chat/db/migrate/20220630074200_drop_chat_isolated_from_user_options.rb
index 0a41149418e..2eac0dc2ac1 100644
--- a/plugins/chat/db/migrate/20220630074200_drop_chat_isolated_from_user_options.rb
+++ b/plugins/chat/db/migrate/20220630074200_drop_chat_isolated_from_user_options.rb
@@ -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) }
diff --git a/plugins/chat/db/migrate/20230403012844_drop_chat_uploads.rb b/plugins/chat/db/migrate/20230403012844_drop_chat_uploads.rb
index d36f031e425..d4c689497ef 100644
--- a/plugins/chat/db/migrate/20230403012844_drop_chat_uploads.rb
+++ b/plugins/chat/db/migrate/20230403012844_drop_chat_uploads.rb
@@ -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) }
diff --git a/plugins/chat/db/post_migrate/20240408140000_drop_notification_id_from_chat_mentions.rb b/plugins/chat/db/post_migrate/20240408140000_drop_notification_id_from_chat_mentions.rb
index 68fa46820c3..e47b969e3ec 100644
--- a/plugins/chat/db/post_migrate/20240408140000_drop_notification_id_from_chat_mentions.rb
+++ b/plugins/chat/db/post_migrate/20240408140000_drop_notification_id_from_chat_mentions.rb
@@ -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) }
diff --git a/plugins/chat/db/post_migrate/20240410130000_drop_user_id_from_chat_mentions.rb b/plugins/chat/db/post_migrate/20240410130000_drop_user_id_from_chat_mentions.rb
index d2ca6216f7b..7295a7e1547 100644
--- a/plugins/chat/db/post_migrate/20240410130000_drop_user_id_from_chat_mentions.rb
+++ b/plugins/chat/db/post_migrate/20240410130000_drop_user_id_from_chat_mentions.rb
@@ -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) }
diff --git a/plugins/chat/db/post_migrate/20240425133407_drop_chat_channels_last_message_sent_at.rb b/plugins/chat/db/post_migrate/20240425133407_drop_chat_channels_last_message_sent_at.rb
index 0a3b61d6c98..27ac0598895 100644
--- a/plugins/chat/db/post_migrate/20240425133407_drop_chat_channels_last_message_sent_at.rb
+++ b/plugins/chat/db/post_migrate/20240425133407_drop_chat_channels_last_message_sent_at.rb
@@ -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) }
diff --git a/plugins/poll/db/migrate/20180820080623_migrate_polls_data.rb b/plugins/poll/db/migrate/20180820080623_migrate_polls_data.rb
index 3eaa55300fa..9e0bff43212 100644
--- a/plugins/poll/db/migrate/20180820080623_migrate_polls_data.rb
+++ b/plugins/poll/db/migrate/20180820080623_migrate_polls_data.rb
@@ -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
diff --git a/plugins/poll/lib/polls_updater.rb b/plugins/poll/lib/polls_updater.rb
index 261e925c712..1b802a70ee5 100644
--- a/plugins/poll/lib/polls_updater.rb
+++ b/plugins/poll/lib/polls_updater.rb
@@ -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
diff --git a/plugins/poll/plugin.rb b/plugins/poll/plugin.rb
index 08ec1e79cb2..40914b47153 100644
--- a/plugins/poll/plugin.rb
+++ b/plugins/poll/plugin.rb
@@ -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
diff --git a/script/bulk_import/base.rb b/script/bulk_import/base.rb
index 25b8b0fbc76..f054eb3fd98 100644
--- a/script/bulk_import/base.rb
+++ b/script/bulk_import/base.rb
@@ -25,8 +25,8 @@ module BulkImport
end
class BulkImport::Base
- NOW ||= "now()"
- PRIVATE_OFFSET ||= 2**30
+ NOW = "now()"
+ PRIVATE_OFFSET = 2**30
CHARSET_MAP = {
"armscii8" => nil,
@@ -475,7 +475,7 @@ class BulkImport::Base
@chat_message_mapping[id.to_s]&.to_i
end
- GROUP_COLUMNS ||= %i[
+ GROUP_COLUMNS = %i[
id
name
full_name
@@ -490,7 +490,7 @@ class BulkImport::Base
updated_at
]
- USER_COLUMNS ||= %i[
+ USER_COLUMNS = %i[
id
username
username_lower
@@ -511,9 +511,9 @@ class BulkImport::Base
updated_at
]
- USER_EMAIL_COLUMNS ||= %i[id user_id email primary created_at updated_at]
+ USER_EMAIL_COLUMNS = %i[id user_id email primary created_at updated_at]
- USER_STAT_COLUMNS ||= %i[
+ USER_STAT_COLUMNS = %i[
user_id
topics_entered
time_read
@@ -531,13 +531,13 @@ class BulkImport::Base
digest_attempted_at
]
- USER_HISTORY_COLUMNS ||= %i[action acting_user_id target_user_id details created_at updated_at]
+ USER_HISTORY_COLUMNS = %i[action acting_user_id target_user_id details created_at updated_at]
- USER_AVATAR_COLUMNS ||= %i[id user_id custom_upload_id created_at updated_at]
+ USER_AVATAR_COLUMNS = %i[id user_id custom_upload_id created_at updated_at]
- USER_PROFILE_COLUMNS ||= %i[user_id location website bio_raw bio_cooked views]
+ USER_PROFILE_COLUMNS = %i[user_id location website bio_raw bio_cooked views]
- USER_SSO_RECORD_COLUMNS ||= %i[
+ USER_SSO_RECORD_COLUMNS = %i[
id
user_id
external_id
@@ -552,7 +552,7 @@ class BulkImport::Base
external_card_background_url
]
- USER_ASSOCIATED_ACCOUNT_COLUMNS ||= %i[
+ USER_ASSOCIATED_ACCOUNT_COLUMNS = %i[
provider_name
provider_uid
user_id
@@ -564,7 +564,7 @@ class BulkImport::Base
updated_at
]
- USER_OPTION_COLUMNS ||= %i[
+ USER_OPTION_COLUMNS = %i[
user_id
mailing_list_mode
mailing_list_mode_frequency
@@ -590,17 +590,17 @@ class BulkImport::Base
timezone
]
- USER_FOLLOWER_COLUMNS ||= %i[user_id follower_id level created_at updated_at]
+ USER_FOLLOWER_COLUMNS = %i[user_id follower_id level created_at updated_at]
- GROUP_USER_COLUMNS ||= %i[group_id user_id created_at updated_at]
+ GROUP_USER_COLUMNS = %i[group_id user_id created_at updated_at]
- USER_CUSTOM_FIELD_COLUMNS ||= %i[user_id name value created_at updated_at]
+ USER_CUSTOM_FIELD_COLUMNS = %i[user_id name value created_at updated_at]
- POST_CUSTOM_FIELD_COLUMNS ||= %i[post_id name value created_at updated_at]
+ POST_CUSTOM_FIELD_COLUMNS = %i[post_id name value created_at updated_at]
- TOPIC_CUSTOM_FIELD_COLUMNS ||= %i[topic_id name value created_at updated_at]
+ TOPIC_CUSTOM_FIELD_COLUMNS = %i[topic_id name value created_at updated_at]
- USER_ACTION_COLUMNS ||= %i[
+ USER_ACTION_COLUMNS = %i[
action_type
user_id
target_topic_id
@@ -611,9 +611,9 @@ class BulkImport::Base
updated_at
]
- MUTED_USER_COLUMNS ||= %i[user_id muted_user_id created_at updated_at]
+ MUTED_USER_COLUMNS = %i[user_id muted_user_id created_at updated_at]
- CATEGORY_COLUMNS ||= %i[
+ CATEGORY_COLUMNS = %i[
id
name
name_lower
@@ -628,15 +628,15 @@ class BulkImport::Base
updated_at
]
- CATEGORY_CUSTOM_FIELD_COLUMNS ||= %i[category_id name value created_at updated_at]
+ CATEGORY_CUSTOM_FIELD_COLUMNS = %i[category_id name value created_at updated_at]
- CATEGORY_GROUP_COLUMNS ||= %i[id category_id group_id permission_type created_at updated_at]
+ CATEGORY_GROUP_COLUMNS = %i[id category_id group_id permission_type created_at updated_at]
- CATEGORY_TAG_GROUP_COLUMNS ||= %i[category_id tag_group_id created_at updated_at]
+ CATEGORY_TAG_GROUP_COLUMNS = %i[category_id tag_group_id created_at updated_at]
- CATEGORY_USER_COLUMNS ||= %i[category_id user_id notification_level last_seen_at]
+ CATEGORY_USER_COLUMNS = %i[category_id user_id notification_level last_seen_at]
- TOPIC_COLUMNS ||= %i[
+ TOPIC_COLUMNS = %i[
id
archetype
title
@@ -657,7 +657,7 @@ class BulkImport::Base
updated_at
]
- POST_COLUMNS ||= %i[
+ POST_COLUMNS = %i[
id
user_id
last_editor_id
@@ -675,7 +675,7 @@ class BulkImport::Base
updated_at
]
- POST_ACTION_COLUMNS ||= %i[
+ POST_ACTION_COLUMNS = %i[
id
post_id
user_id
@@ -695,13 +695,13 @@ class BulkImport::Base
disagreed_by_id
]
- TOPIC_ALLOWED_USER_COLUMNS ||= %i[topic_id user_id created_at updated_at]
+ TOPIC_ALLOWED_USER_COLUMNS = %i[topic_id user_id created_at updated_at]
- TOPIC_ALLOWED_GROUP_COLUMNS ||= %i[topic_id group_id created_at updated_at]
+ TOPIC_ALLOWED_GROUP_COLUMNS = %i[topic_id group_id created_at updated_at]
- TOPIC_TAG_COLUMNS ||= %i[topic_id tag_id created_at updated_at]
+ TOPIC_TAG_COLUMNS = %i[topic_id tag_id created_at updated_at]
- TOPIC_USER_COLUMNS ||= %i[
+ TOPIC_USER_COLUMNS = %i[
user_id
topic_id
last_read_post_number
@@ -713,9 +713,9 @@ class BulkImport::Base
total_msecs_viewed
]
- TAG_USER_COLUMNS ||= %i[tag_id user_id notification_level created_at updated_at]
+ TAG_USER_COLUMNS = %i[tag_id user_id notification_level created_at updated_at]
- UPLOAD_COLUMNS ||= %i[
+ UPLOAD_COLUMNS = %i[
id
user_id
original_filename
@@ -742,9 +742,9 @@ class BulkImport::Base
dominant_color
]
- UPLOAD_REFERENCE_COLUMNS ||= %i[upload_id target_type target_id created_at updated_at]
+ UPLOAD_REFERENCE_COLUMNS = %i[upload_id target_type target_id created_at updated_at]
- OPTIMIZED_IMAGE_COLUMNS ||= %i[
+ OPTIMIZED_IMAGE_COLUMNS = %i[
sha1
extension
width
@@ -758,9 +758,9 @@ class BulkImport::Base
updated_at
]
- POST_VOTING_VOTE_COLUMNS ||= %i[user_id votable_type votable_id direction created_at]
+ POST_VOTING_VOTE_COLUMNS = %i[user_id votable_type votable_id direction created_at]
- BADGE_COLUMNS ||= %i[
+ BADGE_COLUMNS = %i[
id
name
description
@@ -774,11 +774,11 @@ class BulkImport::Base
query
]
- USER_BADGE_COLUMNS ||= %i[badge_id user_id granted_at granted_by_id seq post_id created_at]
+ USER_BADGE_COLUMNS = %i[badge_id user_id granted_at granted_by_id seq post_id created_at]
- GAMIFICATION_SCORE_EVENT_COLUMNS ||= %i[user_id date points description created_at updated_at]
+ GAMIFICATION_SCORE_EVENT_COLUMNS = %i[user_id date points description created_at updated_at]
- POST_EVENT_COLUMNS ||= %i[
+ POST_EVENT_COLUMNS = %i[
id
status
original_starts_at
@@ -794,7 +794,7 @@ class BulkImport::Base
minimal
]
- POST_EVENT_DATES_COLUMNS ||= %i[
+ POST_EVENT_DATES_COLUMNS = %i[
event_id
starts_at
ends_at
@@ -806,7 +806,7 @@ class BulkImport::Base
updated_at
]
- POLL_COLUMNS ||= %i[
+ POLL_COLUMNS = %i[
id
post_id
name
@@ -826,13 +826,13 @@ class BulkImport::Base
title
]
- POLL_OPTION_COLUMNS ||= %i[id poll_id digest html anonymous_votes created_at updated_at]
+ POLL_OPTION_COLUMNS = %i[id poll_id digest html anonymous_votes created_at updated_at]
- POLL_VOTE_COLUMNS ||= %i[poll_id poll_option_id user_id created_at updated_at]
+ POLL_VOTE_COLUMNS = %i[poll_id poll_option_id user_id created_at updated_at]
- PLUGIN_STORE_ROW_COLUMNS ||= %i[plugin_name key type_name value]
+ PLUGIN_STORE_ROW_COLUMNS = %i[plugin_name key type_name value]
- PERMALINK_COLUMNS ||= %i[
+ PERMALINK_COLUMNS = %i[
url
topic_id
post_id
@@ -844,7 +844,7 @@ class BulkImport::Base
updated_at
]
- CHAT_DIRECT_MESSAGE_CHANNEL_COLUMNS ||= %i[id group created_at updated_at]
+ CHAT_DIRECT_MESSAGE_CHANNEL_COLUMNS = %i[id group created_at updated_at]
CHAT_CHANNEL_COLUMNS ||= %i[
id
diff --git a/spec/fixtures/db/post_migrate/drop_column/20990309014014_drop_post_columns.rb b/spec/fixtures/db/post_migrate/drop_column/20990309014014_drop_post_columns.rb
index 556489f2553..aff50e6a5dd 100644
--- a/spec/fixtures/db/post_migrate/drop_column/20990309014014_drop_post_columns.rb
+++ b/spec/fixtures/db/post_migrate/drop_column/20990309014014_drop_post_columns.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropPostColumns < ActiveRecord::Migration[5.2]
- DROPPED_COLUMNS ||= { posts: %i[via_email raw_email] }
+ DROPPED_COLUMNS = { posts: %i[via_email raw_email] }
def up
remove_column :posts, :via_email
diff --git a/spec/fixtures/db/post_migrate/drop_table/20990309014013_drop_email_logs_table.rb b/spec/fixtures/db/post_migrate/drop_table/20990309014013_drop_email_logs_table.rb
index ed8d31d7e64..4a3914c5b2f 100644
--- a/spec/fixtures/db/post_migrate/drop_table/20990309014013_drop_email_logs_table.rb
+++ b/spec/fixtures/db/post_migrate/drop_table/20990309014013_drop_email_logs_table.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class DropEmailLogsTable < ActiveRecord::Migration[5.2]
- DROPPED_TABLES ||= %i[email_logs]
+ DROPPED_TABLES = %i[email_logs]
def up
drop_table :email_logs