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)
category_options = {
is_homepage: current_homepage == "categories".freeze,
is_homepage: current_homepage == "categories",
parent_category_id: params[:parent_category_id],
include_topics: include_topics(parent_category)
}
@ -53,10 +53,10 @@ class CategoriesController < ApplicationController
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.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.more_topics_url = url_for(public_send("top_path"))
end
@ -245,7 +245,7 @@ class CategoriesController < ApplicationController
discourse_expires_in 1.minute
category_options = {
is_homepage: current_homepage == "categories".freeze,
is_homepage: current_homepage == "categories",
parent_category_id: params[:parent_category_id],
include_topics: false
}
@ -354,8 +354,8 @@ class CategoriesController < ApplicationController
view_context.mobile_view? ||
params[:include_topics] ||
(parent_category && parent_category.subcategory_list_includes_topics?) ||
style == "categories_with_featured_topics".freeze ||
style == "categories_boxes_with_topics".freeze ||
style == "categories_with_top_topics".freeze
style == "categories_with_featured_topics" ||
style == "categories_boxes_with_topics" ||
style == "categories_with_top_topics"
end
end

View File

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

View File

@ -36,7 +36,7 @@ module ApplicationHelper
end
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"
return request.env[sk] if request.env[sk]
@ -282,7 +282,7 @@ module ApplicationHelper
'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
def gsub_emoji_to_unicode(str)

View File

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

View File

@ -4,8 +4,8 @@ require 'excon'
module Jobs
class EmitWebHookEvent < ::Jobs::Base
PING_EVENT = 'ping'.freeze
MAX_RETRY_COUNT = 4.freeze
PING_EVENT = 'ping'
MAX_RETRY_COUNT = 4
RETRY_BACKOFF = 5
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
# is set to NULL once a reminder has been sent.
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
every 5.minutes

View File

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

View File

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

View File

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

View File

@ -23,7 +23,7 @@ module Jobs
Email::Processor.process!(popmail.pop)
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
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."))
end
POLL_MAILBOX_ERRORS_KEY ||= "poll_mailbox_errors".freeze
POLL_MAILBOX_ERRORS_KEY ||= "poll_mailbox_errors"
def self.errors_in_past_24_hours
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 :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
# Populates the category featured topics.

View File

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

View File

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

View File

@ -140,9 +140,9 @@ class Emoji
def self.replacement_code(code)
code
.split('-'.freeze)
.split('-')
.map!(&:hex)
.pack("U*".freeze)
.pack("U*")
end
def self.unicode_replacements
@ -166,7 +166,7 @@ class Emoji
replacements[code] = name
if is_tonable_emojis.include?(name)
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}"
end
end

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@ class Upload < ActiveRecord::Base
SHA1_LENGTH = 40
SEEDED_ID_THRESHOLD = 0
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 :access_control_post, class_name: 'Post'

View File

@ -352,7 +352,7 @@ class User < ActiveRecord::Base
end
EMAIL = %r{([^@]+)@([^\.]+)}
FROM_STAGED = "from_staged".freeze
FROM_STAGED = "from_staged"
def self.new_from_params(params)
user = User.new
@ -598,7 +598,7 @@ class User < ActiveRecord::Base
notification = notifications.visible.order('notifications.created_at desc').first
json = NotificationSerializer.new(notification).as_json if notification
sql = (<<~SQL).freeze
sql = (<<~SQL)
SELECT * FROM (
SELECT n.id, n.read FROM notifications n
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)
end
EMAIL_RECEIVER_ERROR_PREFIX = "Email::Receiver::".freeze
EMAIL_RECEIVER_ERROR_PREFIX = "Email::Receiver::"
def error
@error_string.presence || I18n.t("emails.incoming.unrecognized_error")

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
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
def self.send_notification(bookmark)

View File

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

View File

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

View File

@ -6,7 +6,7 @@ module Email
class MessageBuilder
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)
@to = to

View File

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

View File

@ -121,14 +121,14 @@ module FileStore
File.extname(upload.original_filename)
end
get_path_for("original".freeze, upload.id, upload.sha1, extension)
get_path_for("original", upload.id, upload.sha1, extension)
end
def get_path_for_optimized_image(optimized_image)
upload = optimized_image.upload
version = optimized_image.version || 1
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
CACHE_DIR ||= "#{Rails.root}/tmp/download_cache/"

View File

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

View File

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

View File

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

View File

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

View File

@ -311,7 +311,7 @@ module PrettyText
# extract all links
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)
end
end

View File

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

View File

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

View File

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

View File

@ -458,7 +458,7 @@ class TopicQuery
def latest_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_tags(result, @user, options)
result = apply_shared_drafts(result, get_category_id(options[:category]), options)

View File

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

View File

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

View File

@ -2,7 +2,7 @@
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 = {})
@opts = opts

View File

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

View File

@ -26,7 +26,7 @@ module BulkImport; end
class BulkImport::Base
NOW ||= "now()".freeze
NOW ||= "now()"
PRIVATE_OFFSET ||= 2**30
# 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_ids] unless mapped[:imported_ids].nil?
@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
puts "\n"
puts "ERROR: #{e.inspect}"
@ -669,7 +669,7 @@ class BulkImport::Base
end
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
end

View File

@ -4,7 +4,7 @@ require_relative "base"
class BulkImport::DiscourseMerger < BulkImport::Base
NOW ||= "now()".freeze
NOW ||= "now()"
CUSTOM_FIELDS = ['category', 'group', 'post', 'topic', 'user']
# 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|
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"]
@ -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|
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.gsub!(attachment_regex) do |s|
@ -613,7 +613,7 @@ class BulkImport::Vanilla < BulkImport::Base
)
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
@ -645,7 +645,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

View File

@ -608,7 +608,7 @@ class BulkImport::VBulletin < BulkImport::Base
count = 0
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 unless item =~ /avatar(\d+)_(\d).gif/

View File

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

View File

@ -475,7 +475,7 @@ describe DiscourseTagging do
describe "clean_tag" 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
expect(DiscourseTagging.clean_tag("HeLlO")).to eq("HeLlO")

View File

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