Make import scripts work with frozen strings

Make import scripts work with frozen strings

diff --git a/script/import_scripts/answerbase.rb b/script/import_scripts/answerbase.rb
index e011737..1f436ac 100644
--- a/script/import_scripts/answerbase.rb
+++ b/script/import_scripts/answerbase.rb
@@ -255,7 +255,7 @@ class ImportScripts::Answerbase < ImportScripts::Base
         upload = @uploader.create_upload(user_id, path, filename)
 
         if upload.present? && upload.persisted? && !upload_ids.include?(upload.id)
-          raw << "\n" << @uploader.html_for_upload(upload, filename)
+          raw = "#{raw}\n#{@uploader.html_for_upload(upload, filename)}"
         end
       else
         STDERR.puts "Could not find file: #{path}"
diff --git a/script/import_scripts/askbot.rb b/script/import_scripts/askbot.rb
index b4cb4f2..422c8fa 100644
--- a/script/import_scripts/askbot.rb
+++ b/script/import_scripts/askbot.rb
@@ -239,7 +239,7 @@ class ImportScripts::MyAskBot < ImportScripts::Base
     # ask.cvxr.com/question/(\d+)/[^'"}]*
     # I am sure this is incomplete, but we didn't make heavy use of internal
     # links on our site.
-    tmp = Regexp.quote("http://" << OLD_SITE)
+    tmp = Regexp.quote("http://#{OLD_SITE}")
     r1 = /"(#{tmp})?\/question\/(\d+)\/[a-zA-Z-]*\/?"/
     r2 = /\((#{tmp})?\/question\/(\d+)\/[a-zA-Z-]*\/?\)/
     r3 = /<?#tmp\/question\/(\d+)\/[a-zA-Z-]*\/?>?/
diff --git a/script/import_scripts/base/csv_helper.rb b/script/import_scripts/base/csv_helper.rb
index 3a175b9..7f7becb 100644
--- a/script/import_scripts/base/csv_helper.rb
+++ b/script/import_scripts/base/csv_helper.rb
@@ -24,7 +24,7 @@ module ImportScripts
       first = true
       row = nil
 
-      current_row = ""
+      current_row = +""
       double_quote_count = 0
 
       File.open(filename).each_line do |line|
diff --git a/script/import_scripts/bespoke_1.rb b/script/import_scripts/bespoke_1.rb
index 8f36db0..9ca420f 100644
--- a/script/import_scripts/bespoke_1.rb
+++ b/script/import_scripts/bespoke_1.rb
@@ -67,7 +67,7 @@ class ImportScripts::Bespoke < ImportScripts::Base
     first = true
     row = nil
 
-    current_row = ""
+    current_row = +""
     double_quote_count = 0
 
     File.open(filename).each_line do |line|
diff --git a/script/import_scripts/discuz_x.rb b/script/import_scripts/discuz_x.rb
index 750a1ef..dc8f28e 100644
--- a/script/import_scripts/discuz_x.rb
+++ b/script/import_scripts/discuz_x.rb
@@ -787,7 +787,7 @@ class ImportScripts::DiscuzX < ImportScripts::Base
           FROM #{table_name 'forum_attachment'}
           WHERE pid = #{post.custom_fields['import_id']}"
       if !inline_attachments.empty?
-        sql << " AND aid NOT IN (#{inline_attachments.join(',')})"
+        sql = "#{sql} AND aid NOT IN (#{inline_attachments.join(',')})"
       end
 
       results = mysql_query(sql)
diff --git a/script/import_scripts/jive.rb b/script/import_scripts/jive.rb
index c70b3e0..8d386a5 100644
--- a/script/import_scripts/jive.rb
+++ b/script/import_scripts/jive.rb
@@ -69,7 +69,7 @@ class ImportScripts::Jive < ImportScripts::Base
     first = true
     row = nil
 
-    current_row = ""
+    current_row = +""
     double_quote_count = 0
 
     File.open(filename).each_line do |line|
diff --git a/script/import_scripts/jive_api.rb b/script/import_scripts/jive_api.rb
index 62a892a..cf6df4d 100644
--- a/script/import_scripts/jive_api.rb
+++ b/script/import_scripts/jive_api.rb
@@ -129,7 +129,7 @@ class ImportScripts::JiveApi < ImportScripts::Base
       filters = "filter=entityDescriptor(#{entities.join(",")})"
     else
       path = "places/#{place["placeID"]}/contents"
-      filters = "filter=status(published)"
+      filters = +"filter=status(published)"
       if to_import[:filters]
         filters << "&filter=type(#{to_import[:filters][:type]})" if to_import[:filters][:type].present?
         filters << "&filter=creationDate(null,#{to_import[:filters][:created_after].strftime("%Y-%m-%dT%TZ")})" if to_import[:filters][:created_after].present?
diff --git a/script/import_scripts/lithium.rb b/script/import_scripts/lithium.rb
index e6f536f..83700a8 100644
--- a/script/import_scripts/lithium.rb
+++ b/script/import_scripts/lithium.rb
@@ -1021,7 +1021,7 @@ SQL
   end
 
   def html_for_attachments(user_id, files)
-    html = ""
+    html = +""
 
     files.each do |file|
       upload, filename = find_upload(user_id, file["attachment_id"], file["file_name"])
diff --git a/script/import_scripts/mbox/importer.rb b/script/import_scripts/mbox/importer.rb
index 1be6222..3d823e1 100644
--- a/script/import_scripts/mbox/importer.rb
+++ b/script/import_scripts/mbox/importer.rb
@@ -137,7 +137,7 @@ module ImportScripts::Mbox
         body = receiver.add_attachments(body, user)
       end
 
-      body << Email::Receiver.elided_html(elided) if elided.present?
+      body = "#{body}#{Email::Receiver.elided_html(elided)}" if elided.present?
       body
     end
 
diff --git a/script/import_scripts/mbox/support/indexer.rb b/script/import_scripts/mbox/support/indexer.rb
index 4a24e9f..fa51ef6 100644
--- a/script/import_scripts/mbox/support/indexer.rb
+++ b/script/import_scripts/mbox/support/indexer.rb
@@ -155,7 +155,7 @@ module ImportScripts::Mbox
     end
 
     def each_mail(filename)
-      raw_message = ''
+      raw_message = +''
       first_line_number = 1
       last_line_number = 0
 
@@ -165,7 +165,7 @@ module ImportScripts::Mbox
         if line =~ @split_regex
           if last_line_number > 0
             yield raw_message, first_line_number, last_line_number
-            raw_message = ''
+            raw_message = +''
             first_line_number = last_line_number + 1
           end
         else
diff --git a/script/import_scripts/nabble.rb b/script/import_scripts/nabble.rb
index e405486..e877e90 100644
--- a/script/import_scripts/nabble.rb
+++ b/script/import_scripts/nabble.rb
@@ -283,7 +283,7 @@ class String
   def indent(count, char = ' ')
     gsub(/([^\n]*)(\n|$)/) do |match|
       last_iteration = ($1 == "" && $2 == "")
-      line = ""
+      line = +""
       line << (char * count) unless last_iteration
       line << $1
       line << $2
diff --git a/script/import_scripts/phpbb3/database/database.rb b/script/import_scripts/phpbb3/database/database.rb
index 70cc4e4..6b34feb 100644
--- a/script/import_scripts/phpbb3/database/database.rb
+++ b/script/import_scripts/phpbb3/database/database.rb
@@ -26,8 +26,10 @@ module ImportScripts::PhpBB3
         require_relative 'database_3_1'
         Database_3_1.new(@database_client, @database_settings)
       else
-        raise UnsupportedVersionError, "Unsupported version (#{version}) of phpBB detected.\n" \
-          << 'Currently only 3.0.x and 3.1.x are supported by this importer.'
+        raise UnsupportedVersionError, <<~MSG
+          Unsupported version (#{version}) of phpBB detected.
+          Currently only 3.0.x and 3.1.x are supported by this importer.
+        MSG
       end
     end
 
diff --git a/script/import_scripts/phpbb3/importers/poll_importer.rb b/script/import_scripts/phpbb3/importers/poll_importer.rb
index 023de32..82066bf 100644
--- a/script/import_scripts/phpbb3/importers/poll_importer.rb
+++ b/script/import_scripts/phpbb3/importers/poll_importer.rb
@@ -56,7 +56,7 @@ module ImportScripts::PhpBB3
     # @param poll_data [ImportScripts::PhpBB3::PollData]
     def get_poll_text(poll_data)
       title = @text_processor.process_raw_text(poll_data.title)
-      text = "#{title}\n\n"
+      text = +"#{title}\n\n"
 
       arguments = ["results=always"]
       arguments << "close=#{poll_data.close_time.iso8601}" if poll_data.close_time
diff --git a/script/import_scripts/smf2.rb b/script/import_scripts/smf2.rb
index e24c9ca..1471d20 100644
--- a/script/import_scripts/smf2.rb
+++ b/script/import_scripts/smf2.rb
@@ -319,7 +319,7 @@ class ImportScripts::Smf2 < ImportScripts::Base
       "\n[#{tag}]#{$~[:inner].strip}[/#{tag}]\n"
     end
     body.gsub!(XListPattern) do |s|
-      r = "\n[ul]"
+      r = +"\n[ul]"
       s.lines.each { |l| r << '[li]' << l.strip.sub(/^\[x\]\s*/, '') << '[/li]' }

[... diff too long, it was truncated ...]

GitHub sha: 0f3c3bc3

2 Likes