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("■") - CACHE_VERSION ||= 3 + REPLACEMENT_LETTER = CGI.unescape_html("■") + 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 ? "