DEV: enable frozen string literal on all files

This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
This commit is contained in:
Sam Saffron
2019-05-03 08:17:27 +10:00
committed by Guo Xiang Tan
parent 4e1f25197d
commit 30990006a9
2201 changed files with 4482 additions and 90 deletions

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "socket"
require "csv"
require "yaml"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'benchmark/ips'
require File.expand_path('../../../../config/environment', __FILE__)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'memory_profiler'
require 'benchmark/ips'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'benchmark/ips'
require File.expand_path('../../../../config/environment', __FILE__)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'ruby-prof'
def profile(&blk)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# simple script to measure memory at boot
if ENV['RAILS_ENV'] != "production"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
if ARGV.include?('bbcode-to-md')
# Replace (most) bbcode with markdown before creating posts.
# This will dramatically clean up the final posts in Discourse.

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_relative "base"
class BulkImport::DiscourseMerger < BulkImport::Base

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_relative "base"
require "pg"
require "htmlentities"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_relative "base"
require "mysql2"
require "rake"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_relative "base"
require "set"
require "mysql2"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require File.expand_path("../../config/environment", __FILE__)
def pretty

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
ctx = MiniRacer::Context.new(timeout: 15000)
ctx.eval("var self = this; #{File.read("#{Rails.root}/vendor/assets/javascripts/babel.js")}")
ctx.eval(File.read(Ember::Source.bundled_path_for('ember-template-compiler.js')))

View File

@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
$parent_pid = ARGV[0].to_i

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require File.expand_path("../../../config/environment", __FILE__)
puts "Parent is now loaded"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# to be used to compare ruby heaps generated in 2.1
# can isolate memory leaks
#

View File

@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require "thor"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# This script is run in the discourse_test docker image
# Available environment variables:
# => NO_UPDATE disables updating the source code within the discourse_test docker image

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require File.expand_path("../../config/environment", __FILE__)
# no less than 1 megapixel

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'csv'
require 'reverse_markdown'
require_relative 'base'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
require 'pg'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
if ARGV.include?('bbcode-to-md')
# Replace (most) bbcode with markdown before creating posts.
# This will dramatically clean up the final posts in Discourse.

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ImportScripts
module CsvHelper
class RowResolver

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'sqlite3'
module ImportScripts

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ImportScripts
class LookupContainer
def initialize

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_dependency 'url_helper'
require_dependency 'file_helper'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'mysql2'
require File.expand_path(File.dirname(__FILE__) + "/base.rb")

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# bespoke importer for a customer, feel free to borrow ideas
require 'csv'

View File

@@ -1,4 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
#
# Author: Erick Guan <fantasticfears@gmail.com>
#

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'nokogiri'
require 'optparse'
require File.expand_path(File.dirname(__FILE__) + "/base")

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "mysql2"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "mysql2"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
# Edit the constants and initialize method for your import data.

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "mysql2"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
require File.expand_path(File.dirname(__FILE__) + "/drupal.rb")

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "mysql2"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
require 'csv'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# getsatisfaction importer
#
# pre-req: You will either get an Excel or a bunch of CSV files. Be sure to rename them all so that

View File

@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require "bundler/inline"

View File

@@ -1,4 +1,6 @@
# coding: utf-8
# frozen_string_literal: true
require "mysql2"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
require 'htmlentities'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "mysql2"
require "reverse_markdown"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Jive importer
require 'nokogiri'
require 'csv'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "nokogiri"
require "htmlentities"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "csv"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "mysql2"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "mysql2"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Notes:
#
# Written by Sam

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
if ARGV.length != 1 || !File.exists?(ARGV[0])
STDERR.puts '', 'Usage of mbox importer:', 'bundle exec ruby mbox.rb <path/to/settings.yml>'
STDERR.puts '', "Use the settings file from #{File.expand_path('mbox/settings.yml', File.dirname(__FILE__))} as an example."

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_relative '../base'
require_relative 'support/database'
require_relative 'support/indexer'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'sqlite3'
module ImportScripts::Mbox

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_relative 'database'
require 'json'
require 'yaml'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'yaml'
module ImportScripts::Mbox

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'mysql2'
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
require 'htmlentities'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "csv"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "mysql2"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "mysql2"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
require 'htmlentities'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
require 'pg'
require_relative 'base/uploader'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
# Edit the constants and initialize method for your import data.

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_relative '../base.rb'
require_relative './redis'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'redis'
module NodeBB

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "mysql2"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Importer for phpBB 3.0 and 3.1
# Documentation: https://meta.discourse.org/t/importing-from-phpbb3/30810

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'mysql2'
module ImportScripts::PhpBB3

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_relative 'database_base'
require_relative '../support/constants'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_relative 'database_3_0'
require_relative '../support/constants'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ImportScripts::PhpBB3
class DatabaseBase
# @param database_client [Mysql2::Client]

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_relative '../base'
require_relative 'support/settings'
require_relative 'database/database'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ImportScripts::PhpBB3
class AttachmentImporter
# @param database [ImportScripts::PhpBB3::Database_3_0 | ImportScripts::PhpBB3::Database_3_1]

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ImportScripts::PhpBB3
class AvatarImporter
# @param uploader [ImportScripts::Uploader]

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ImportScripts::PhpBB3
class BookmarkImporter
def map_bookmark(row)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ImportScripts::PhpBB3
class CategoryImporter
# @param lookup [ImportScripts::LookupContainer]

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_relative 'attachment_importer'
require_relative 'avatar_importer'
require_relative 'bookmark_importer'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ImportScripts::PhpBB3
class MessageImporter
# @param database [ImportScripts::PhpBB3::Database_3_0 | ImportScripts::PhpBB3::Database_3_1]

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ImportScripts::PhpBB3
class PermalinkImporter
CATEGORY_LINK_NORMALIZATION = '/(viewforum.php\?)(?:.*&)?(f=\d+).*/\1\2'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ImportScripts::PhpBB3
class PollImporter
# @param lookup [ImportScripts::LookupContainer]

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ImportScripts::PhpBB3
class PostImporter
# @param lookup [ImportScripts::LookupContainer]

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_relative '../support/constants'
module ImportScripts::PhpBB3

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ImportScripts::PhpBB3
class Constants
ACTIVE_USER = 0

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'yaml'
module ImportScripts::PhpBB3

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ImportScripts::PhpBB3
class SmileyProcessor
# @param uploader [ImportScripts::Uploader]

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ImportScripts::PhpBB3
class TextProcessor
# @param lookup [ImportScripts::LookupContainer]

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "mysql2"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'yaml'
require_relative 'quandora_api'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_relative './quandora_question.rb'
require File.expand_path(File.dirname(__FILE__) + "/../base.rb")

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'base64'
require 'json'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'json'
require 'cgi'
require 'time'

View File

@@ -1,3 +1,4 @@
# frozen_string_literal: true
BASES = '{
"type" : "kbase",
"data" : [ {

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'minitest/autorun'
require 'yaml'
require_relative '../quandora_api.rb'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'minitest/autorun'
require 'cgi'
require 'time'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'mysql2'
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
require 'htmlentities'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# custom importer for www.sfn.org, feel free to borrow ideas
require "csv"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'mysql2'
require File.expand_path(File.dirname(__FILE__) + "/base.rb")

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "mysql2"
require "htmlentities"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")

View File

@@ -1,4 +1,6 @@
# coding: utf-8
# frozen_string_literal: true
require 'mysql2'
require File.expand_path(File.dirname(__FILE__) + '/base.rb')

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'uri'
class CreateTitle

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'yaml'
require 'fileutils'
require_relative 'socialcast_api'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_relative './socialcast_message.rb'
require_relative './socialcast_user.rb'
require 'set'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'base64'
require 'json'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'json'
require 'cgi'
require 'time'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'json'
require 'cgi'
require 'time'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'minitest/autorun'
require_relative '../create_title.rb'

Some files were not shown because too many files have changed in this diff Show More