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

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

View File

@@ -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

View File

@@ -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/, "")

View File

@@ -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,

View File

@@ -107,7 +107,7 @@ module Onebox
),
)
DISCOURSE_ONEBOX ||=
DISCOURSE_ONEBOX =
Sanitize::Config.freeze_config(
Sanitize::Config.merge(
ONEBOX,