DEV: stop freezing frozen strings

We have the `# frozen_string_literal: true` comment on all our
files. This means all string literals are frozen. There is no need
to call #freeze on any literals.

For files with `# frozen_string_literal: true`

```
puts %w{a b}[0].frozen?
=> true

puts "hi".frozen?
=> true

puts "a #{1} b".frozen?
=> true

puts ("a " + "b").frozen?
=> false

puts (-("a " + "b")).frozen?
=> true
```

For more details see: https://samsaffron.com/archive/2018/02/16/reducing-string-duplication-in-ruby
This commit is contained in:
Sam Saffron 2020-04-30 16:48:34 +10:00
parent 02ef88052d
commit d0d5a138c3
No known key found for this signature in database
GPG Key ID: B9606168D2FFD9F5
51 changed files with 98 additions and 98 deletions

View File

@ -24,7 +24,7 @@ class CategoriesController < ApplicationController
parent_category = Category.find_by_slug(params[:parent_category_id]) || Category.find_by(id: params[:parent_category_id].to_i) parent_category = Category.find_by_slug(params[:parent_category_id]) || Category.find_by(id: params[:parent_category_id].to_i)
category_options = { category_options = {
is_homepage: current_homepage == "categories".freeze, is_homepage: current_homepage == "categories",
parent_category_id: params[:parent_category_id], parent_category_id: params[:parent_category_id],
include_topics: include_topics(parent_category) include_topics: include_topics(parent_category)
} }
@ -53,10 +53,10 @@ class CategoriesController < ApplicationController
no_definitions: true no_definitions: true
} }
if style == "categories_and_latest_topics".freeze if style == "categories_and_latest_topics"
@topic_list = TopicQuery.new(current_user, topic_options).list_latest @topic_list = TopicQuery.new(current_user, topic_options).list_latest
@topic_list.more_topics_url = url_for(public_send("latest_path")) @topic_list.more_topics_url = url_for(public_send("latest_path"))
elsif style == "categories_and_top_topics".freeze elsif style == "categories_and_top_topics"
@topic_list = TopicQuery.new(nil, topic_options).list_top_for(SiteSetting.top_page_default_timeframe.to_sym) @topic_list = TopicQuery.new(nil, topic_options).list_top_for(SiteSetting.top_page_default_timeframe.to_sym)
@topic_list.more_topics_url = url_for(public_send("top_path")) @topic_list.more_topics_url = url_for(public_send("top_path"))
end end
@ -245,7 +245,7 @@ class CategoriesController < ApplicationController
discourse_expires_in 1.minute discourse_expires_in 1.minute
category_options = { category_options = {
is_homepage: current_homepage == "categories".freeze, is_homepage: current_homepage == "categories",
parent_category_id: params[:parent_category_id], parent_category_id: params[:parent_category_id],
include_topics: false include_topics: false
} }
@ -354,8 +354,8 @@ class CategoriesController < ApplicationController
view_context.mobile_view? || view_context.mobile_view? ||
params[:include_topics] || params[:include_topics] ||
(parent_category && parent_category.subcategory_list_includes_topics?) || (parent_category && parent_category.subcategory_list_includes_topics?) ||
style == "categories_with_featured_topics".freeze || style == "categories_with_featured_topics" ||
style == "categories_boxes_with_topics".freeze || style == "categories_boxes_with_topics" ||
style == "categories_with_top_topics".freeze style == "categories_with_top_topics"
end end
end end

View File

@ -15,13 +15,13 @@ class WebhooksController < ActionController::Base
events.each do |event| events.each do |event|
message_id = (event["smtp-id"] || "").tr("<>", "") message_id = (event["smtp-id"] || "").tr("<>", "")
to_address = event["email"] to_address = event["email"]
if event["event"] == "bounce".freeze if event["event"] == "bounce"
if event["status"]["4."] if event["status"]["4."]
process_bounce(message_id, to_address, SiteSetting.soft_bounce_score) process_bounce(message_id, to_address, SiteSetting.soft_bounce_score)
else else
process_bounce(message_id, to_address, SiteSetting.hard_bounce_score) process_bounce(message_id, to_address, SiteSetting.hard_bounce_score)
end end
elsif event["event"] == "dropped".freeze elsif event["event"] == "dropped"
process_bounce(message_id, to_address, SiteSetting.hard_bounce_score) process_bounce(message_id, to_address, SiteSetting.hard_bounce_score)
end end
end end
@ -34,7 +34,7 @@ class WebhooksController < ActionController::Base
events.each do |event| events.each do |event|
message_id = event["CustomID"] message_id = event["CustomID"]
to_address = event["email"] to_address = event["email"]
if event["event"] == "bounce".freeze if event["event"] == "bounce"
if event["hard_bounce"] if event["hard_bounce"]
process_bounce(message_id, to_address, SiteSetting.hard_bounce_score) process_bounce(message_id, to_address, SiteSetting.hard_bounce_score)
else else
@ -156,9 +156,9 @@ class WebhooksController < ActionController::Base
# only handle soft bounces, because hard bounces are also handled # only handle soft bounces, because hard bounces are also handled
# by the "dropped" event and we don't want to increase bounce score twice # by the "dropped" event and we don't want to increase bounce score twice
# for the same message # for the same message
if event == "bounced".freeze && params["error"]["4."] if event == "bounced" && params["error"]["4."]
process_bounce(message_id, to_address, SiteSetting.soft_bounce_score) process_bounce(message_id, to_address, SiteSetting.soft_bounce_score)
elsif event == "dropped".freeze elsif event == "dropped"
process_bounce(message_id, to_address, SiteSetting.hard_bounce_score) process_bounce(message_id, to_address, SiteSetting.hard_bounce_score)
end end
@ -174,10 +174,10 @@ class WebhooksController < ActionController::Base
to_address = data["recipient"] to_address = data["recipient"]
severity = data["severity"] severity = data["severity"]
if data["event"] == "failed".freeze if data["event"] == "failed"
if severity == "temporary".freeze if severity == "temporary"
process_bounce(message_id, to_address, SiteSetting.soft_bounce_score) process_bounce(message_id, to_address, SiteSetting.soft_bounce_score)
elsif severity == "permanent".freeze elsif severity == "permanent"
process_bounce(message_id, to_address, SiteSetting.hard_bounce_score) process_bounce(message_id, to_address, SiteSetting.hard_bounce_score)
end end
end end

View File

@ -36,7 +36,7 @@ module ApplicationHelper
end end
def shared_session_key def shared_session_key
if SiteSetting.long_polling_base_url != '/'.freeze && current_user if SiteSetting.long_polling_base_url != '/' && current_user
sk = "shared_session_key" sk = "shared_session_key"
return request.env[sk] if request.env[sk] return request.env[sk] if request.env[sk]
@ -282,7 +282,7 @@ module ApplicationHelper
'query-input' => 'required name=search_term_string', 'query-input' => 'required name=search_term_string',
} }
} }
content_tag(:script, MultiJson.dump(json).html_safe, type: 'application/ld+json'.freeze) content_tag(:script, MultiJson.dump(json).html_safe, type: 'application/ld+json')
end end
def gsub_emoji_to_unicode(str) def gsub_emoji_to_unicode(str)

View File

@ -2,8 +2,8 @@
module Jobs module Jobs
class BulkUserTitleUpdate < ::Jobs::Base class BulkUserTitleUpdate < ::Jobs::Base
UPDATE_ACTION = 'update'.freeze UPDATE_ACTION = 'update'
RESET_ACTION = 'reset'.freeze RESET_ACTION = 'reset'
def execute(args) def execute(args)
new_title = args[:new_title] new_title = args[:new_title]

View File

@ -4,8 +4,8 @@ require 'excon'
module Jobs module Jobs
class EmitWebHookEvent < ::Jobs::Base class EmitWebHookEvent < ::Jobs::Base
PING_EVENT = 'ping'.freeze PING_EVENT = 'ping'
MAX_RETRY_COUNT = 4.freeze MAX_RETRY_COUNT = 4
RETRY_BACKOFF = 5 RETRY_BACKOFF = 5
def execute(args) def execute(args)

View File

@ -6,7 +6,7 @@ module Jobs
# Any leftovers will be caught in the next run, because the reminder_at column # Any leftovers will be caught in the next run, because the reminder_at column
# is set to NULL once a reminder has been sent. # is set to NULL once a reminder has been sent.
class BookmarkReminderNotifications < ::Jobs::Scheduled class BookmarkReminderNotifications < ::Jobs::Scheduled
JOB_RUN_NUMBER_KEY ||= 'jobs_bookmark_reminder_notifications_job_run_num'.freeze JOB_RUN_NUMBER_KEY ||= 'jobs_bookmark_reminder_notifications_job_run_num'
AT_DESKTOP_CONSISTENCY_RUN_NUMBER ||= 6 AT_DESKTOP_CONSISTENCY_RUN_NUMBER ||= 6
every 5.minutes every 5.minutes

View File

@ -41,7 +41,7 @@ module Jobs
end end
def self.last_notified_key def self.last_notified_key
"last_notified_queued_post_id".freeze "last_notified_queued_post_id"
end end
end end
end end

View File

@ -45,7 +45,7 @@ module Jobs
end end
def self.last_notified_key def self.last_notified_key
"last_notified_reviewable_id".freeze "last_notified_reviewable_id"
end end
def self.clear_key def self.clear_key

View File

@ -58,7 +58,7 @@ module Jobs
end end
def previous_newest_username_cache_key def previous_newest_username_cache_key
"pending-users-reminder:newest-username".freeze "pending-users-reminder:newest-username"
end end
end end

View File

@ -23,7 +23,7 @@ module Jobs
Email::Processor.process!(popmail.pop) Email::Processor.process!(popmail.pop)
end end
POLL_MAILBOX_TIMEOUT_ERROR_KEY ||= "poll_mailbox_timeout_error_key".freeze POLL_MAILBOX_TIMEOUT_ERROR_KEY ||= "poll_mailbox_timeout_error_key"
def poll_pop3 def poll_pop3
pop3 = Net::POP3.new(SiteSetting.pop3_polling_host, SiteSetting.pop3_polling_port) pop3 = Net::POP3.new(SiteSetting.pop3_polling_host, SiteSetting.pop3_polling_port)
@ -62,7 +62,7 @@ module Jobs
Discourse.handle_job_exception(e, error_context(@args, "Signing in to poll incoming emails.")) Discourse.handle_job_exception(e, error_context(@args, "Signing in to poll incoming emails."))
end end
POLL_MAILBOX_ERRORS_KEY ||= "poll_mailbox_errors".freeze POLL_MAILBOX_ERRORS_KEY ||= "poll_mailbox_errors"
def self.errors_in_past_24_hours def self.errors_in_past_24_hours
Discourse.redis.zremrangebyscore(POLL_MAILBOX_ERRORS_KEY, 0, 24.hours.ago.to_i) Discourse.redis.zremrangebyscore(POLL_MAILBOX_ERRORS_KEY, 0, 24.hours.ago.to_i)

View File

@ -4,7 +4,7 @@ class CategoryFeaturedTopic < ActiveRecord::Base
belongs_to :category belongs_to :category
belongs_to :topic belongs_to :topic
NEXT_CATEGORY_ID_KEY = 'category-featured-topic:next-category-id'.freeze NEXT_CATEGORY_ID_KEY = 'category-featured-topic:next-category-id'
DEFAULT_BATCH_SIZE = 100 DEFAULT_BATCH_SIZE = 100
# Populates the category featured topics. # Populates the category featured topics.

View File

@ -40,7 +40,7 @@ class CategoryList
end end
def preload_key def preload_key
"categories_list".freeze "categories_list"
end end
def self.order_categories(categories) def self.order_categories(categories)

View File

@ -3,7 +3,7 @@
module CategoryHashtag module CategoryHashtag
extend ActiveSupport::Concern extend ActiveSupport::Concern
SEPARATOR = ":".freeze SEPARATOR = ":"
class_methods do class_methods do
def query_from_hashtag_slug(category_slug) def query_from_hashtag_slug(category_slug)

View File

@ -140,9 +140,9 @@ class Emoji
def self.replacement_code(code) def self.replacement_code(code)
code code
.split('-'.freeze) .split('-')
.map!(&:hex) .map!(&:hex)
.pack("U*".freeze) .pack("U*")
end end
def self.unicode_replacements def self.unicode_replacements
@ -166,7 +166,7 @@ class Emoji
replacements[code] = name replacements[code] = name
if is_tonable_emojis.include?(name) if is_tonable_emojis.include?(name)
fitzpatrick_scales.each_with_index do |scale, index| fitzpatrick_scales.each_with_index do |scale, index|
toned_code = code.codepoints.insert(1, scale).pack("U*".freeze) toned_code = code.codepoints.insert(1, scale).pack("U*")
replacements[toned_code] = "#{name}:t#{index + 2}" replacements[toned_code] = "#{name}:t#{index + 2}"
end end
end end

View File

@ -228,7 +228,7 @@ class Topic < ActiveRecord::Base
end end
after_save do after_save do
banner = "banner".freeze banner = "banner"
if archetype_before_last_save == banner || archetype == banner if archetype_before_last_save == banner || archetype == banner
ApplicationController.banner_json_cache.clear ApplicationController.banner_json_cache.clear

View File

@ -119,7 +119,7 @@ class TopicLink < ActiveRecord::Base
uri = UrlHelper.relaxed_parse(u.url) uri = UrlHelper.relaxed_parse(u.url)
[u, uri] [u, uri]
end end
.reject { |_, p| p.nil? || "mailto".freeze == p.scheme } .reject { |_, p| p.nil? || "mailto" == p.scheme }
.uniq { |_, p| p } .uniq { |_, p| p }
.each do |link, parsed| .each do |link, parsed|

View File

@ -10,9 +10,9 @@ class TopicTrackingState
include ActiveModel::SerializerSupport include ActiveModel::SerializerSupport
CHANNEL = "/user-tracking" CHANNEL = "/user-tracking"
UNREAD_MESSAGE_TYPE = "unread".freeze UNREAD_MESSAGE_TYPE = "unread"
LATEST_MESSAGE_TYPE = "latest".freeze LATEST_MESSAGE_TYPE = "latest"
MUTED_MESSAGE_TYPE = "muted".freeze MUTED_MESSAGE_TYPE = "muted"
attr_accessor :user_id, attr_accessor :user_id,
:topic_id, :topic_id,

View File

@ -9,7 +9,7 @@ class Upload < ActiveRecord::Base
SHA1_LENGTH = 40 SHA1_LENGTH = 40
SEEDED_ID_THRESHOLD = 0 SEEDED_ID_THRESHOLD = 0
URL_REGEX ||= /(\/original\/\dX[\/\.\w]*\/([a-zA-Z0-9]+)[\.\w]*)/ URL_REGEX ||= /(\/original\/\dX[\/\.\w]*\/([a-zA-Z0-9]+)[\.\w]*)/
SECURE_MEDIA_ROUTE = "secure-media-uploads".freeze SECURE_MEDIA_ROUTE = "secure-media-uploads"
belongs_to :user belongs_to :user
belongs_to :access_control_post, class_name: 'Post' belongs_to :access_control_post, class_name: 'Post'

View File

@ -352,7 +352,7 @@ class User < ActiveRecord::Base
end end
EMAIL = %r{([^@]+)@([^\.]+)} EMAIL = %r{([^@]+)@([^\.]+)}
FROM_STAGED = "from_staged".freeze FROM_STAGED = "from_staged"
def self.new_from_params(params) def self.new_from_params(params)
user = User.new user = User.new
@ -598,7 +598,7 @@ class User < ActiveRecord::Base
notification = notifications.visible.order('notifications.created_at desc').first notification = notifications.visible.order('notifications.created_at desc').first
json = NotificationSerializer.new(notification).as_json if notification json = NotificationSerializer.new(notification).as_json if notification
sql = (<<~SQL).freeze sql = (<<~SQL)
SELECT * FROM ( SELECT * FROM (
SELECT n.id, n.read FROM notifications n SELECT n.id, n.read FROM notifications n
LEFT JOIN topics t ON n.topic_id = t.id LEFT JOIN topics t ON n.topic_id = t.id

View File

@ -15,7 +15,7 @@ class IncomingEmailDetailsSerializer < ApplicationSerializer
@mail = Mail.new(incoming_email.raw) @mail = Mail.new(incoming_email.raw)
end end
EMAIL_RECEIVER_ERROR_PREFIX = "Email::Receiver::".freeze EMAIL_RECEIVER_ERROR_PREFIX = "Email::Receiver::"
def error def error
@error_string.presence || I18n.t("emails.incoming.unrecognized_error") @error_string.presence || I18n.t("emails.incoming.unrecognized_error")

View File

@ -180,7 +180,7 @@ class BadgeGranter
end end
def self.queue_key def self.queue_key
"badge_queue".freeze "badge_queue"
end end
# Options: # Options:

View File

@ -1,8 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
class SilenceLogger < Rails::Rack::Logger class SilenceLogger < Rails::Rack::Logger
PATH_INFO = 'PATH_INFO'.freeze PATH_INFO = 'PATH_INFO'
HTTP_X_SILENCE_LOGGER = 'HTTP_X_SILENCE_LOGGER'.freeze HTTP_X_SILENCE_LOGGER = 'HTTP_X_SILENCE_LOGGER'
def initialize(app, opts = {}) def initialize(app, opts = {})
@app = app @app = app
@ -36,9 +36,9 @@ class SilenceLogger < Rails::Rack::Logger
end end
silenced = [ silenced = [
"/mini-profiler-resources/results".freeze, "/mini-profiler-resources/results",
"/mini-profiler-resources/includes.js".freeze, "/mini-profiler-resources/includes.js",
"/mini-profiler-resources/includes.css".freeze, "/mini-profiler-resources/includes.css",
"/mini-profiler-resources/jquery.tmpl.js".freeze "/mini-profiler-resources/jquery.tmpl.js"
] ]
Rails.configuration.middleware.swap Rails::Rack::Logger, SilenceLogger, silenced: silenced Rails.configuration.middleware.swap Rails::Rack::Logger, SilenceLogger, silenced: silenced

View File

@ -11,7 +11,7 @@ class PostgreSQLFallbackHandler
attr_reader :masters_down attr_reader :masters_down
attr_accessor :initialized attr_accessor :initialized
DATABASE_DOWN_CHANNEL = '/global/database_down'.freeze DATABASE_DOWN_CHANNEL = '/global/database_down'
def initialize def initialize
@masters_down = DistributedCache.new('masters_down', namespace: false) @masters_down = DistributedCache.new('masters_down', namespace: false)

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
class BadgePostsViewManager class BadgePostsViewManager
VIEW_NAME = "badge_posts".freeze VIEW_NAME = "badge_posts"
def self.create! def self.create!
sql = <<~SQL sql = <<~SQL

View File

@ -3,7 +3,7 @@
# Modified version of: https://github.com/steventen/base62-rb # Modified version of: https://github.com/steventen/base62-rb
module Base62 module Base62
KEYS ||= "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".freeze KEYS ||= "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
KEYS_HASH ||= KEYS.each_char.with_index.to_h KEYS_HASH ||= KEYS.each_char.with_index.to_h
BASE ||= KEYS.length BASE ||= KEYS.length

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
class BookmarkReminderNotificationHandler class BookmarkReminderNotificationHandler
PENDING_AT_DESKTOP_KEY_PREFIX ||= 'pending_at_desktop_bookmark_reminder_user_'.freeze PENDING_AT_DESKTOP_KEY_PREFIX ||= 'pending_at_desktop_bookmark_reminder_user_'
PENDING_AT_DESKTOP_EXPIRY_DAYS ||= 20 PENDING_AT_DESKTOP_EXPIRY_DAYS ||= 20
def self.send_notification(bookmark) def self.send_notification(bookmark)

View File

@ -42,7 +42,7 @@ module Discourse
end end
def self.pretty_logs(logs) def self.pretty_logs(logs)
logs.join("\n".freeze) logs.join("\n")
end end
def self.atomic_write_file(destination, contents) def self.atomic_write_file(destination, contents)
@ -811,7 +811,7 @@ module Discourse
warning warning
end end
SIDEKIQ_NAMESPACE ||= 'sidekiq'.freeze SIDEKIQ_NAMESPACE ||= 'sidekiq'
def self.sidekiq_redis_config def self.sidekiq_redis_config
conf = GlobalSetting.redis_config.dup conf = GlobalSetting.redis_config.dup

View File

@ -8,10 +8,10 @@ class DiscourseRedis
class FallbackHandler class FallbackHandler
include Singleton include Singleton
MASTER_ROLE_STATUS = "role:master".freeze MASTER_ROLE_STATUS = "role:master"
MASTER_LOADING_STATUS = "loading:1".freeze MASTER_LOADING_STATUS = "loading:1"
MASTER_LOADED_STATUS = "loading:0".freeze MASTER_LOADED_STATUS = "loading:0"
CONNECTION_TYPES = %w{normal pubsub}.each(&:freeze) CONNECTION_TYPES = %w{normal pubsub}
def initialize def initialize
@master = true @master = true

View File

@ -6,7 +6,7 @@ module Email
class MessageBuilder class MessageBuilder
attr_reader :template_args attr_reader :template_args
ALLOW_REPLY_BY_EMAIL_HEADER = 'X-Discourse-Allow-Reply-By-Email'.freeze ALLOW_REPLY_BY_EMAIL_HEADER = 'X-Discourse-Allow-Reply-By-Email'
def initialize(to, opts = nil) def initialize(to, opts = nil)
@to = to @to = to

View File

@ -337,8 +337,8 @@ module Email
def strip_classes_and_ids def strip_classes_and_ids
@fragment.css('*').each do |element| @fragment.css('*').each do |element|
element.delete('class'.freeze) element.delete('class')
element.delete('id'.freeze) element.delete('id')
end end
end end

View File

@ -121,14 +121,14 @@ module FileStore
File.extname(upload.original_filename) File.extname(upload.original_filename)
end end
get_path_for("original".freeze, upload.id, upload.sha1, extension) get_path_for("original", upload.id, upload.sha1, extension)
end end
def get_path_for_optimized_image(optimized_image) def get_path_for_optimized_image(optimized_image)
upload = optimized_image.upload upload = optimized_image.upload
version = optimized_image.version || 1 version = optimized_image.version || 1
extension = "_#{version}_#{optimized_image.width}x#{optimized_image.height}#{optimized_image.extension}" extension = "_#{version}_#{optimized_image.width}x#{optimized_image.height}#{optimized_image.extension}"
get_path_for("optimized".freeze, upload.id, upload.sha1, extension) get_path_for("optimized", upload.id, upload.sha1, extension)
end end
CACHE_DIR ||= "#{Rails.root}/tmp/download_cache/" CACHE_DIR ||= "#{Rails.root}/tmp/download_cache/"

View File

@ -240,11 +240,11 @@ class HtmlPrettify < String
def educate_fractions(str) def educate_fractions(str)
str.gsub(/(\s+|^)(1\/4|1\/2|3\/4)([,.;\s]|$)/) do str.gsub(/(\s+|^)(1\/4|1\/2|3\/4)([,.;\s]|$)/) do
frac = frac =
if $2 == "1/2".freeze if $2 == "1/2"
entity(:frac12) entity(:frac12)
elsif $2 == "1/4".freeze elsif $2 == "1/4"
entity(:frac14) entity(:frac14)
elsif $2 == "3/4".freeze elsif $2 == "3/4"
entity(:frac34) entity(:frac34)
end end
"#{$1}#{frac}#{$3}" "#{$1}#{frac}#{$3}"

View File

@ -2,7 +2,7 @@
module Migration module Migration
class BaseDropper class BaseDropper
FUNCTION_SCHEMA_NAME ||= "discourse_functions".freeze FUNCTION_SCHEMA_NAME ||= "discourse_functions"
def self.create_readonly_function(table_name, column_name = nil) def self.create_readonly_function(table_name, column_name = nil)
DB.exec <<~SQL DB.exec <<~SQL

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
class PlainTextToMarkdown class PlainTextToMarkdown
SIGNATURE_SEPARATOR ||= "-- ".freeze SIGNATURE_SEPARATOR ||= "-- "
def initialize(plaintext, opts = {}) def initialize(plaintext, opts = {})
@plaintext = plaintext @plaintext = plaintext

View File

@ -240,7 +240,7 @@ class PostCreator
end end
def self.track_post_stats def self.track_post_stats
Rails.env != "test".freeze || @track_post_stats Rails.env != "test" || @track_post_stats
end end
def self.track_post_stats=(val) def self.track_post_stats=(val)

View File

@ -311,7 +311,7 @@ module PrettyText
# extract all links # extract all links
doc.css("a").each do |a| doc.css("a").each do |a|
if a["href"].present? && a["href"][0] != "#".freeze if a["href"].present? && a["href"][0] != "#"
links << DetectedLink.new(a["href"], false) links << DetectedLink.new(a["href"], false)
end end
end end

View File

@ -2,7 +2,7 @@
class QuoteComparer class QuoteComparer
def self.whitespace def self.whitespace
" \t\r\n".freeze " \t\r\n"
end end
def initialize(topic_id, post_number, text) def initialize(topic_id, post_number, text)

View File

@ -28,7 +28,7 @@ class S3Helper
end end
def self.get_bucket_and_folder_path(s3_bucket_name) def self.get_bucket_and_folder_path(s3_bucket_name)
s3_bucket_name.downcase.split("/".freeze, 2) s3_bucket_name.downcase.split("/", 2)
end end
def upload(file, path, options = {}) def upload(file, path, options = {})
@ -75,7 +75,7 @@ class S3Helper
options[:copy_source] = File.join(@s3_bucket_name, source) options[:copy_source] = File.join(@s3_bucket_name, source)
elsif @s3_bucket_folder_path elsif @s3_bucket_folder_path
folder, filename = begin folder, filename = begin
source.split("/".freeze, 2) source.split("/", 2)
end end
options[:copy_source] = File.join(@s3_bucket_name, folder, multisite_upload_path, filename) options[:copy_source] = File.join(@s3_bucket_name, folder, multisite_upload_path, filename)
else else

View File

@ -135,7 +135,7 @@ module SiteSettingExtension
if GlobalSetting.respond_to?(name) if GlobalSetting.respond_to?(name)
val = GlobalSetting.public_send(name) val = GlobalSetting.public_send(name)
unless val.nil? || (val == ''.freeze) unless val.nil? || (val == '')
shadowed_val = val shadowed_val = val
hidden_settings << name hidden_settings << name
shadowed_settings << name shadowed_settings << name

View File

@ -458,7 +458,7 @@ class TopicQuery
def latest_results(options = {}) def latest_results(options = {})
result = default_results(options) result = default_results(options)
result = remove_muted_topics(result, @user) unless options && options[:state] == "muted".freeze result = remove_muted_topics(result, @user) unless options && options[:state] == "muted"
result = remove_muted_categories(result, @user, exclude: options[:category]) result = remove_muted_categories(result, @user, exclude: options[:category])
result = remove_muted_tags(result, @user, options) result = remove_muted_tags(result, @user, options)
result = apply_shared_drafts(result, get_category_id(options[:category]), options) result = apply_shared_drafts(result, get_category_id(options[:category]), options)

View File

@ -93,7 +93,7 @@ class TwitterApi
end end
unless defined? BASE_URL unless defined? BASE_URL
BASE_URL = 'https://api.twitter.com'.freeze BASE_URL = 'https://api.twitter.com'
end end
def twitter_get(uri) def twitter_get(uri)

View File

@ -29,7 +29,7 @@ class CensoredWordsValidator < ActiveModel::EachValidator
def join_censored_words(censored_words) def join_censored_words(censored_words)
censored_words.map!(&:downcase) censored_words.map!(&:downcase)
censored_words.uniq! censored_words.uniq!
censored_words.join(", ".freeze) censored_words.join(", ")
end end
def censored_words_regexp def censored_words_regexp

View File

@ -2,7 +2,7 @@
class RegexSettingValidator class RegexSettingValidator
LOREM = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam eget sem non elit tincidunt rhoncus.'.freeze LOREM = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam eget sem non elit tincidunt rhoncus.'
def initialize(opts = {}) def initialize(opts = {})
@opts = opts @opts = opts

View File

@ -5,8 +5,8 @@ require 'webauthn/security_key_registration_service'
require 'webauthn/security_key_authentication_service' require 'webauthn/security_key_authentication_service'
module Webauthn module Webauthn
ACCEPTABLE_REGISTRATION_TYPE = "webauthn.create".freeze ACCEPTABLE_REGISTRATION_TYPE = "webauthn.create"
ACCEPTABLE_AUTHENTICATION_TYPE = "webauthn.get".freeze ACCEPTABLE_AUTHENTICATION_TYPE = "webauthn.get"
# -7 - ES256 # -7 - ES256
# -257 - RS256 (Windows Hello supported alg.) # -257 - RS256 (Windows Hello supported alg.)

View File

@ -26,7 +26,7 @@ module BulkImport; end
class BulkImport::Base class BulkImport::Base
NOW ||= "now()".freeze NOW ||= "now()"
PRIVATE_OFFSET ||= 2**30 PRIVATE_OFFSET ||= 2**30
# rubocop:disable Layout/HashAlignment # rubocop:disable Layout/HashAlignment
@ -660,7 +660,7 @@ class BulkImport::Base
imported_ids << mapped[:imported_id] unless mapped[:imported_id].nil? imported_ids << mapped[:imported_id] unless mapped[:imported_id].nil?
imported_ids |= mapped[:imported_ids] unless mapped[:imported_ids].nil? imported_ids |= mapped[:imported_ids] unless mapped[:imported_ids].nil?
@raw_connection.put_copy_data columns.map { |c| processed[c] } @raw_connection.put_copy_data columns.map { |c| processed[c] }
print "\r%7d - %6d/sec".freeze % [imported_ids.size, imported_ids.size.to_f / (Time.now - start)] if imported_ids.size % 5000 == 0 print "\r%7d - %6d/sec" % [imported_ids.size, imported_ids.size.to_f / (Time.now - start)] if imported_ids.size % 5000 == 0
rescue => e rescue => e
puts "\n" puts "\n"
puts "ERROR: #{e.inspect}" puts "ERROR: #{e.inspect}"
@ -669,7 +669,7 @@ class BulkImport::Base
end end
if imported_ids.size > 0 if imported_ids.size > 0
print "\r%7d - %6d/sec".freeze % [imported_ids.size, imported_ids.size.to_f / (Time.now - start)] print "\r%7d - %6d/sec" % [imported_ids.size, imported_ids.size.to_f / (Time.now - start)]
puts puts
end end

View File

@ -4,7 +4,7 @@ require_relative "base"
class BulkImport::DiscourseMerger < BulkImport::Base class BulkImport::DiscourseMerger < BulkImport::Base
NOW ||= "now()".freeze NOW ||= "now()"
CUSTOM_FIELDS = ['category', 'group', 'post', 'topic', 'user'] CUSTOM_FIELDS = ['category', 'group', 'post', 'topic', 'user']
# DB_NAME: name of database being merged into the current local db # DB_NAME: name of database being merged into the current local db

View File

@ -209,7 +209,7 @@ class BulkImport::Vanilla < BulkImport::Base
User.find_each do |u| User.find_each do |u|
count += 1 count += 1
print "\r%7d - %6d/sec".freeze % [count, count.to_f / (Time.now - start)] print "\r%7d - %6d/sec" % [count, count.to_f / (Time.now - start)]
next unless u.custom_fields["import_id"] next unless u.custom_fields["import_id"]
@ -276,7 +276,7 @@ class BulkImport::Vanilla < BulkImport::Base
Post.where("raw LIKE '%/us.v-cdn.net/%' OR raw LIKE '%[attachment%'").find_each do |post| Post.where("raw LIKE '%/us.v-cdn.net/%' OR raw LIKE '%[attachment%'").find_each do |post|
count += 1 count += 1
print "\r%7d - %6d/sec".freeze % [count, count.to_f / (Time.now - start)] print "\r%7d - %6d/sec" % [count, count.to_f / (Time.now - start)]
new_raw = post.raw.dup new_raw = post.raw.dup
new_raw.gsub!(attachment_regex) do |s| new_raw.gsub!(attachment_regex) do |s|
@ -613,7 +613,7 @@ class BulkImport::Vanilla < BulkImport::Base
) )
end end
print "\r%7d - %6d/sec".freeze % [count, count.to_f / (Time.now - start)] if count % 5000 == 0 print "\r%7d - %6d/sec" % [count, count.to_f / (Time.now - start)] if count % 5000 == 0
end end
end end
@ -645,7 +645,7 @@ class BulkImport::Vanilla < BulkImport::Base
end end
end end
print "\r%7d - %6d/sec".freeze % [count, count.to_f / (Time.now - start)] if count % 5000 == 0 print "\r%7d - %6d/sec" % [count, count.to_f / (Time.now - start)] if count % 5000 == 0
end end
end end
end end

View File

@ -608,7 +608,7 @@ class BulkImport::VBulletin < BulkImport::Base
count = 0 count = 0
Dir.foreach(AVATAR_DIR) do |item| Dir.foreach(AVATAR_DIR) do |item|
print "\r%7d - %6d/sec".freeze % [count, count.to_f / (Time.now - start)] print "\r%7d - %6d/sec" % [count, count.to_f / (Time.now - start)]
next if item == ('.') || item == ('..') || item == ('.DS_Store') next if item == ('.') || item == ('..') || item == ('.DS_Store')
next unless item =~ /avatar(\d+)_(\d).gif/ next unless item =~ /avatar(\d+)_(\d).gif/

View File

@ -39,7 +39,7 @@ module ImportScripts::Mbox
private private
METADATA_FILENAME = 'metadata.yml'.freeze METADATA_FILENAME = 'metadata.yml'
IGNORED_FILE_EXTENSIONS = ['.dbindex', '.dbnames', '.digest', '.subjects', '.yml'] IGNORED_FILE_EXTENSIONS = ['.dbindex', '.dbnames', '.digest', '.subjects', '.yml']
def index_category(directory) def index_category(directory)

View File

@ -475,7 +475,7 @@ describe DiscourseTagging do
describe "clean_tag" do describe "clean_tag" do
it "downcases new tags if setting enabled" do it "downcases new tags if setting enabled" do
expect(DiscourseTagging.clean_tag("HeLlO".freeze)).to eq("hello") expect(DiscourseTagging.clean_tag("HeLlO")).to eq("hello")
SiteSetting.force_lowercase_tags = false SiteSetting.force_lowercase_tags = false
expect(DiscourseTagging.clean_tag("HeLlO")).to eq("HeLlO") expect(DiscourseTagging.clean_tag("HeLlO")).to eq("HeLlO")

View File

@ -19,23 +19,23 @@ module WebauthnIntegrationHelpers
# simulate_localhost_webautn_challenge for a real example. # simulate_localhost_webautn_challenge for a real example.
def valid_security_key_data def valid_security_key_data
{ {
credential_id: "9GiFosW50+s+juyJlyxKEVAsk3gZLo9XWIhX47eC4gHfDsldF3TWR43Tcl/+3gLTL5t1TjpmcbKA2DUV2eKrBw==".freeze, credential_id: "9GiFosW50+s+juyJlyxKEVAsk3gZLo9XWIhX47eC4gHfDsldF3TWR43Tcl/+3gLTL5t1TjpmcbKA2DUV2eKrBw==",
public_key: "pQECAyYgASFYIPMGM1OpSuCU5uks+BulAdfVxdlJiYcgGac5Y+LnLXC9Ilgghy0BKvRvptmQdtWz33Jjnf8Y6+HD85XdRiqmo1KMGPE=".freeze public_key: "pQECAyYgASFYIPMGM1OpSuCU5uks+BulAdfVxdlJiYcgGac5Y+LnLXC9Ilgghy0BKvRvptmQdtWz33Jjnf8Y6+HD85XdRiqmo1KMGPE="
} }
end end
def valid_security_key_auth_post_data def valid_security_key_auth_post_data
{ {
signature: "MEYCIQC5xyUQvF4qTPZ2yX7crp/IEs1E/4wqhXgxC1EVAumhfgIhAIC/7w4BVEy+ew6vMYISahtnnIqbqsPZosBeTUSI8Y4j".freeze, signature: "MEYCIQC5xyUQvF4qTPZ2yX7crp/IEs1E/4wqhXgxC1EVAumhfgIhAIC/7w4BVEy+ew6vMYISahtnnIqbqsPZosBeTUSI8Y4j",
clientData: "eyJjaGFsbGVuZ2UiOiJOR1UzWW1Zek0yWTBNelkyWkdFM05EVTNZak5qWldVNFpUWTNOakJoTm1NMFlqVTVORFptTlRrd016Vm1ZMlZpTURVd01UZzJOemcxTW1RMSIsIm9yaWdpbiI6Imh0dHA6Ly9sb2NhbGhvc3Q6MzAwMCIsInR5cGUiOiJ3ZWJhdXRobi5nZXQifQ==".freeze, clientData: "eyJjaGFsbGVuZ2UiOiJOR1UzWW1Zek0yWTBNelkyWkdFM05EVTNZak5qWldVNFpUWTNOakJoTm1NMFlqVTVORFptTlRrd016Vm1ZMlZpTURVd01UZzJOemcxTW1RMSIsIm9yaWdpbiI6Imh0dHA6Ly9sb2NhbGhvc3Q6MzAwMCIsInR5cGUiOiJ3ZWJhdXRobi5nZXQifQ==",
authenticatorData: "SZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2MBAAAA2Q==".freeze, authenticatorData: "SZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2MBAAAA2Q==",
credentialId: valid_security_key_data[:credential_id] credentialId: valid_security_key_data[:credential_id]
} }
end end
def valid_security_key_challenge_data def valid_security_key_challenge_data
{ {
challenge: "4e7bf33f4366da7457b3cee8e6760a6c4b5946f59035fceb0501867852d5".freeze challenge: "4e7bf33f4366da7457b3cee8e6760a6c4b5946f59035fceb0501867852d5"
} }
end end