Skip to content
Permalink
Browse files

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
  • Loading branch information...
SamSaffron authored and Guo Xiang Tan committed May 2, 2019
1 parent 4e1f251 commit 30990006a92bd64eb6c49dc3139a17ce8fd1dc89
Showing 2,201 changed files with 4,482 additions and 90 deletions.
@@ -12,6 +12,9 @@ AllCops:
Style/AndOr:
Enabled: true

Style/FrozenStringLiteralComment:
Enabled: true

# Do not use braces for hash literals when they are the last argument of a
# method call.
Style/BracesAroundHashParameters:
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Install development dependencies on Mac OS X using Homebrew (http://mxcl.github.com/homebrew)

# you probably already have git installed; ensure that it is the latest version
@@ -1,3 +1,5 @@
# frozen_string_literal: true

if github.pr_json && (github.pr_json["additions"] || 0) > 250 || (github.pr_json["deletions"] || 0) > 250
warn("This pull request is big! We prefer smaller PRs whenever possible, as they are easier to review. Can this be split into a few smaller PRs?")
end
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'
# if there is a super emergency and rubygems is playing up, try
#source 'http://production.cf.rubygems.org'
@@ -1,4 +1,6 @@
#!/usr/bin/env rake
# frozen_string_literal: true

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'rate_limiter'

class AboutController < ApplicationController
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'upload_creator'

class Admin::EmojisController < Admin::AdminController
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'flag_query'

class Admin::FlaggedTopicsController < Admin::AdminController
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'flag_query'

class Admin::FlagsController < Admin::AdminController
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Admin::GroupsController < Admin::AdminController
def bulk
end
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Admin::ImpersonateController < Admin::AdminController

def create
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Admin::PermalinksController < Admin::AdminController

before_action :fetch_permalink, only: [:destroy]
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Admin::PluginsController < Admin::AdminController

def index
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'report'

class Admin::ReportsController < Admin::AdminController
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Admin::ScreenedEmailsController < Admin::AdminController

def index
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'ip_addr'

class Admin::ScreenedIpAddressesController < Admin::AdminController
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Admin::ScreenedUrlsController < Admin::AdminController

def index
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Admin::SearchLogsController < Admin::AdminController

def index
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Admin::SiteSettingsController < Admin::AdminController
rescue_from Discourse::InvalidParameters do |e|
render_json_error e.message, status: 422
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'seed_data/categories'
require_dependency 'seed_data/topics'

@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Admin::StaffActionLogsController < Admin::AdminController

def index
@@ -22,7 +24,7 @@ def diff

diff_fields = {}

output = "<h2>#{CGI.escapeHTML(cur["name"].to_s)}</h2><p></p>"
output = +"<h2>#{CGI.escapeHTML(cur["name"].to_s)}</h2><p></p>"

diff_fields["name"] = {
prev: prev["name"].to_s,
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'upload_creator'
require_dependency 'theme_store/tgz_exporter'
require 'base64'
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Admin::UserFieldsController < Admin::AdminController

def self.columns
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'user_destroyer'
require_dependency 'admin_user_index_query'
require_dependency 'admin_confirmation'
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'discourse_updates'

class Admin::VersionsController < Admin::AdminController
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Admin::WatchedWordsController < Admin::AdminController

def index
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Admin::WebHooksController < Admin::AdminController
before_action :fetch_web_hook, only: %i(show update destroy list_events bulk_events ping)

@@ -1,3 +1,5 @@
# frozen_string_literal: true

class BadgesController < ApplicationController
skip_before_action :check_xhr, only: [:index, :show]

@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'category_serializer'

class CategoriesController < ApplicationController
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CategoryHashtagsController < ApplicationController
requires_login

@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ClicksController < ApplicationController
skip_before_action :check_xhr, :preload_json, :verify_authenticity_token

@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'html_to_markdown'

class ComposerController < ApplicationController
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'composer_messages_finder'

class ComposerMessagesController < ApplicationController
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class DirectoryItemsController < ApplicationController
PAGE_SIZE = 50

@@ -1,3 +1,5 @@
# frozen_string_literal: true

class DraftController < ApplicationController
requires_login

@@ -1,3 +1,5 @@
# frozen_string_literal: true

class DraftsController < ApplicationController
requires_login

@@ -1,3 +1,5 @@
# frozen_string_literal: true

class EmailController < ApplicationController
layout 'no_ember'

@@ -1,3 +1,5 @@
# frozen_string_literal: true

class EmbedController < ApplicationController
skip_before_action :check_xhr, :preload_json, :verify_authenticity_token

@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ExceptionsController < ApplicationController
skip_before_action :check_xhr, :preload_json
before_action :hide_search
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ExportCsvController < ApplicationController

skip_before_action :preload_json, :check_xhr, only: [:show]
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class FinishInstallationController < ApplicationController
skip_before_action :check_xhr, :preload_json, :redirect_to_login_if_required
layout 'finish_installation'
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class GroupsController < ApplicationController
include ApplicationHelper

@@ -1,3 +1,5 @@
# frozen_string_literal: true

class HighlightJsController < ApplicationController
skip_before_action :preload_json, :redirect_to_login_if_required, :check_xhr, :verify_authenticity_token, only: [:show]

@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'inline_oneboxer'

class InlineOneboxController < ApplicationController
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'rate_limiter'

class InvitesController < ApplicationController
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'topic_list_responder'

class ListController < ApplicationController
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'notification_serializer'

class NotificationsController < ApplicationController
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class OfflineController < ApplicationController
layout false
skip_before_action :preload_json, :check_xhr, :redirect_to_login_if_required
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'oneboxer'

class OneboxController < ApplicationController
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class PermalinksController < ApplicationController
skip_before_action :check_xhr, :preload_json

@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'discourse'

class PostActionUsersController < ApplicationController
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'discourse'

class PostActionsController < ApplicationController
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'new_post_manager'
require_dependency 'post_creator'
require_dependency 'post_action_destroyer'
@@ -762,7 +764,7 @@ def create_params
end

def signature_for(args)
"post##" << Digest::SHA1.hexdigest(args
+"post##" << Digest::SHA1.hexdigest(args
.to_h
.to_a
.concat([["user", current_user.id]])
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class PushNotificationController < ApplicationController
layout false
before_action :ensure_logged_in
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'queued_post_serializer'

class QueuedPostsController < ApplicationController
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class QunitController < ApplicationController
skip_before_action :check_xhr, :preload_json, :redirect_to_login_if_required
layout false
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class RobotsTxtController < ApplicationController
layout false
skip_before_action :preload_json, :check_xhr, :redirect_to_login_if_required
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class SafeModeController < ApplicationController
layout 'no_ember'
before_action :ensure_safe_mode_enabled
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'search'

class SearchController < ApplicationController
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'rate_limiter'
require_dependency 'single_sign_on'
require_dependency 'single_sign_on_provider'
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'similar_topic_serializer'
require_dependency 'search/grouped_search_results'

@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'site_serializer'

class SiteController < ApplicationController

0 comments on commit 3099000

Please sign in to comment.
You can’t perform that action at this time.