mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
committed by
Guo Xiang Tan
parent
4e1f25197d
commit
30990006a9
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
if ENV['DISCOURSE_DUMP_HEAP'] == "1"
|
||||
require 'objspace'
|
||||
ObjectSpace.trace_object_allocations_start
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
Discourse::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Load the rails application
|
||||
require File.expand_path('../application', __FILE__)
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
Discourse::Application.configure do
|
||||
|
||||
# Settings specified here will take precedence over those in config/application.rb
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
Discourse::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
Discourse::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
Discourse::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb
|
||||
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'mini_sql_multisite_connection'
|
||||
::DB = MiniSqlMultisiteConnection.instance
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
unless Discourse.skip_post_deployment_migrations?
|
||||
Rails.application.config.paths['db/migrate'] << Rails.root.join(
|
||||
Discourse::DB_POST_MIGRATE_PATH
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
if Rails.env.development? && ENV['DISCOURSE_FLUSH_REDIS']
|
||||
puts "Flushing redis (development mode)"
|
||||
$redis.flushall
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
Dir["#{Rails.root}/lib/freedom_patches/*.rb"].each do |f|
|
||||
require(f)
|
||||
end
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'sql_builder'
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
MessageBus.site_id_lookup do |env = nil|
|
||||
if env
|
||||
setup_message_bus_env(env)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# load up git version into memory
|
||||
# this way if it changes underneath we still have
|
||||
# the original version
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Some sanity checking so we don't count on an unindexed column on boot
|
||||
begin
|
||||
if ActiveRecord::Base.connection.table_exists?(:users) &&
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# If Mini Profiler is included via gem
|
||||
if Rails.configuration.respond_to?(:load_mini_profiler) && Rails.configuration.load_mini_profiler
|
||||
require 'rack-mini-profiler'
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "openssl"
|
||||
require "openid_redis_store"
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'discourse_iife'
|
||||
|
||||
Rails.application.config.assets.configure do |env|
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rack/protection'
|
||||
|
||||
Rails.configuration.middleware.use Rack::Protection::FrameOptions
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
%i(
|
||||
topic_recovered
|
||||
).each do |event|
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
Excon::DEFAULTS[:omit_default_port] = true
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_dependency "site_icon_manager"
|
||||
|
||||
DiscourseEvent.on(:site_setting_changed) do |name, old_value, new_value|
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# tiny middleware to force https if needed
|
||||
class Discourse::ForceHttpsMiddleware
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "middleware/anonymous_cache"
|
||||
|
||||
enabled =
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_dependency 'scheduler/defer'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# pg performs inconsistently with large amounts of connections
|
||||
Discourse.start_connection_reaper
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# order: after 02-freedom_patches.rb
|
||||
|
||||
require 'i18n/backend/discourse_i18n'
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
if Rails.env.development? && RUBY_VERSION.match?(/^2\.5\.[23]/)
|
||||
STDERR.puts "WARNING: Discourse development environment runs slower on Ruby 2.5.3 or below"
|
||||
STDERR.puts "We recommend you upgrade to Ruby 2.6.1 for the optimal development performance"
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Not sure why it's not using this by default!
|
||||
MultiJson.engine = :oj
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_dependency 'twitter_api'
|
||||
|
||||
Onebox.options = {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_dependency 'webpush'
|
||||
|
||||
if SiteSetting.vapid_public_key.blank? || SiteSetting.vapid_private_key.blank? || SiteSetting.vapid_public_key_bytes.blank?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
Rails.application.config.assets.configure do |env|
|
||||
env.logger = Logger.new('/dev/null')
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Not fussed setting secret_token anymore, that is only required for
|
||||
# backwards support of "seamless" upgrade from Rails 3.
|
||||
# Discourse has shipped Rails 3 for a very long time.
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Be sure to restart your server when you modify this file.
|
||||
#
|
||||
require_dependency 'discourse_cookie_store'
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "sidekiq/pausable"
|
||||
|
||||
Sidekiq.configure_client do |config|
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SilenceLogger < Rails::Rack::Logger
|
||||
PATH_INFO = 'PATH_INFO'.freeze
|
||||
HTTP_X_SILENCE_LOGGER = 'HTTP_X_SILENCE_LOGGER'.freeze
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
ActiveRecord::Base.public_send(:include, ActiveModel::ForbiddenAttributesProtection)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Check that the app is configured correctly. Raise some helpful errors if something is wrong.
|
||||
|
||||
if defined?(Rails::Server) && Rails.env.production? # Only run these checks when starting up a production server
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# this is a trivial graceful restart on touch of tmp/restart.
|
||||
#
|
||||
# It simply drains all the requests (waits up to 4 seconds) and issues a HUP
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Be sure to restart your server when you modify this file.
|
||||
#
|
||||
# This file contains settings for ActionController::ParamsWrapper which
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
if (Rails.env.production? && SiteSetting.logging_provider == 'lograge') || ENV["ENABLE_LOGRAGE"]
|
||||
require 'lograge'
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# we want MesageBus in the absolute front
|
||||
# this is important cause the vast majority of web requests go to it
|
||||
# this allows us to avoid full middleware crawls each time
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
# source: https://github.com/svenfuchs/i18n/blob/master/test/test_data/locales/plurals.rb
|
||||
|
||||
{
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
if ENV['RAILS_ENV'] == 'production'
|
||||
|
||||
# First, you need to change these below to your situation.
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "sidekiq/web"
|
||||
require "mini_scheduler/web"
|
||||
require_dependency "admin_constraint"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# spring speeds up your dev environment, similar to zeus but build in Ruby
|
||||
#
|
||||
# gem install spring
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# See http://unicorn.bogomips.org/Unicorn/Configurator.html
|
||||
|
||||
if ENV["LOGSTASH_UNICORN_URI"]
|
||||
|
||||
Reference in New Issue
Block a user