mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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/
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user