DEV: use #frozen_string_literal: true on all spec

This change both speeds up specs (less strings to allocate) and helps catch
cases where methods in Discourse are mutating inputs.

Overall we will be migrating everything to use #frozen_string_literal: true
it will take a while, but this is the first and safest move in this direction
This commit is contained in:
Sam Saffron 2019-04-30 10:27:42 +10:00
parent 0a5a6dfded
commit 4ea21fa2d0
658 changed files with 1306 additions and 13 deletions

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'active_record/connection_adapters/postgresql_fallback_adapter' require_dependency 'active_record/connection_adapters/postgresql_fallback_adapter'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'admin_confirmation' require 'admin_confirmation'
require 'rails_helper' require 'rails_helper'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'admin_user_index_query' require_dependency 'admin_user_index_query'

View File

@ -1,4 +1,5 @@
# encoding: utf-8 # encoding: utf-8
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'archetype' require 'archetype'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'auth/default_current_user_provider' require_dependency 'auth/default_current_user_provider'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
describe Auth::FacebookAuthenticator do describe Auth::FacebookAuthenticator do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
def auth_token_for(user) def auth_token_for(user)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
describe Auth::GoogleOAuth2Authenticator do describe Auth::GoogleOAuth2Authenticator do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
describe Auth::InstagramAuthenticator do describe Auth::InstagramAuthenticator do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
describe Auth::ManagedAuthenticator do describe Auth::ManagedAuthenticator do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
describe Auth::OpenIdAuthenticator do describe Auth::OpenIdAuthenticator do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
describe Auth::TwitterAuthenticator do describe Auth::TwitterAuthenticator do

View File

@ -1,4 +1,5 @@
# encoding: utf-8 # encoding: utf-8
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'avatar_lookup' require_dependency 'avatar_lookup'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'cache' require 'cache'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'category_badge' require 'category_badge'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "rails_helper" require "rails_helper"
require_dependency "common_passwords/common_passwords" require_dependency "common_passwords/common_passwords"

View File

@ -1,4 +1,6 @@
# encoding: utf-8 # encoding: utf-8
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'composer_messages_finder' require 'composer_messages_finder'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
describe CategoryHashtag do describe CategoryHashtag do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "rails_helper" require "rails_helper"
describe HasCustomFields do describe HasCustomFields do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "rails_helper" require "rails_helper"
describe HasSearchData do describe HasSearchData do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "rails_helper" require "rails_helper"
describe Positionable do describe Positionable do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "rails_helper" require "rails_helper"
describe Searchable do describe Searchable do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
RSpec.describe SecondFactorManager do RSpec.describe SecondFactorManager do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'content_buffer' require 'content_buffer'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "rails_helper" require "rails_helper"
require "cooked_post_processor" require "cooked_post_processor"
require "file_store/s3_store" require "file_store/s3_store"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'crawler_detection' require_dependency 'crawler_detection'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'current_user' require_dependency 'current_user'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'directory_helper' require_dependency 'directory_helper'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'discourse_diff' require 'discourse_diff'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'discourse_event' require_dependency 'discourse_event'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'discourse_hub' require_dependency 'discourse_hub'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'i18n/backend/discourse_i18n' require 'i18n/backend/discourse_i18n'
require 'translation_override' require 'translation_override'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'discourse_plugin_registry' require 'discourse_plugin_registry'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'discourse_plugin' require_dependency 'discourse_plugin'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
describe DiscourseRedis do describe DiscourseRedis do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'discourse' require 'discourse'

View File

@ -1,4 +1,5 @@
# encoding: UTF-8 # encoding: UTF-8
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'discourse_tagging' require 'discourse_tagging'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'discourse_updates' require_dependency 'discourse_updates'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'distributed_memoizer' require_dependency 'distributed_memoizer'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'distributed_mutex' require_dependency 'distributed_mutex'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'email' require 'email'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'email/message_builder' require 'email/message_builder'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "rails_helper" require "rails_helper"
require "email/processor" require "email/processor"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "rails_helper" require "rails_helper"
require "email/receiver" require "email/receiver"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'email/renderer' require 'email/renderer'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'email/sender' require 'email/sender'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'email' require 'email'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'email_cook' require 'email_cook'
require 'pretty_text' require 'pretty_text'
@ -22,7 +24,7 @@ describe EmailCook do
Vestibulum feugiat mi vitae turpis tempor dignissim. Vestibulum feugiat mi vitae turpis tempor dignissim.
LONG_EMAIL LONG_EMAIL
long_cooked = <<~LONG_COOKED.strip! long_cooked = (+<<~LONG_COOKED).strip!
Hello, Hello,
<br> <br>
<br>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc convallis volutpat <br>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc convallis volutpat
@ -45,7 +47,7 @@ describe EmailCook do
Stet clita kasd gubergren. Stet clita kasd gubergren.
LONG_EMAIL LONG_EMAIL
long_cooked = <<~LONG_COOKED.strip! long_cooked = (+<<~LONG_COOKED).strip!
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc convallis volutpat Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc convallis volutpat
risus. risus.
<br>Nulla ac faucibus quam, quis cursus lorem. Sed rutrum eget nunc sed accumsan. <br>Nulla ac faucibus quam, quis cursus lorem. Sed rutrum eget nunc sed accumsan.
@ -70,7 +72,7 @@ describe EmailCook do
Nunc convallis volutpat risus. Nunc convallis volutpat risus.
LONG_EMAIL LONG_EMAIL
long_cooked = <<~LONG_COOKED.strip! long_cooked = (+<<~LONG_COOKED).strip!
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
<br> <br>
<br>&lt;form name=&quot;f1&quot; method=&quot;post&quot; action=&quot;test.html&quot; onsubmit=&quot;javascript:showAlert()&quot;&gt; <br>&lt;form name=&quot;f1&quot; method=&quot;post&quot; action=&quot;test.html&quot; onsubmit=&quot;javascript:showAlert()&quot;&gt;
@ -94,7 +96,7 @@ describe EmailCook do
no indentation, but lots of spaces no indentation, but lots of spaces
LONG_EMAIL LONG_EMAIL
long_cooked = <<~LONG_COOKED.strip! long_cooked = (+<<~LONG_COOKED).strip!
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
<br> <br>
<br>#{nbsp}#{nbsp}#{nbsp}#{nbsp}this is indended by 4 spaces <br>#{nbsp}#{nbsp}#{nbsp}#{nbsp}this is indended by 4 spaces

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'email_updater' require_dependency 'email_updater'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'email' require 'email'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "rails_helper" require "rails_helper"
require "excerpt_parser" require "excerpt_parser"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'i18n/backend/fallback_locale_list' require 'i18n/backend/fallback_locale_list'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'feed_element_installer' require 'feed_element_installer'
require 'rails_helper' require 'rails_helper'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rss' require 'rss'
require 'feed_item_accessor' require 'feed_item_accessor'
require 'rails_helper' require 'rails_helper'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'file_helper' require 'file_helper'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'file_store/base_store' require_dependency 'file_store/base_store'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'file_store/local_store' require 'file_store/local_store'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'file_store/s3_store' require 'file_store/s3_store'
require 'file_store/local_store' require 'file_store/local_store'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'filter_best_posts' require 'filter_best_posts'
require 'topic_view' require 'topic_view'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'final_destination' require 'final_destination'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'flag_query' require_dependency 'flag_query'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'flag_settings' require 'flag_settings'

View File

@ -1,13 +1,15 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency "freedom_patches/safe_buffer" require_dependency "freedom_patches/safe_buffer"
describe ActiveSupport::SafeBuffer do describe ActiveSupport::SafeBuffer do
it "can cope with encoding weirdness" do it "can cope with encoding weirdness" do
buffer = ActiveSupport::SafeBuffer.new buffer = ActiveSupport::SafeBuffer.new
buffer << "\330".force_encoding("ASCII-8BIT") buffer << (+"\330").force_encoding("ASCII-8BIT")
buffer.force_encoding "ASCII-8BIT" buffer.force_encoding "ASCII-8BIT"
buffer << "hello\330\271" buffer << "hello\330\271"
buffer << "hello#{254.chr}".force_encoding("ASCII-8BIT").freeze buffer << (+"hello#{254.chr}").force_encoding("ASCII-8BIT").freeze
# we pay a cost for force encoding, the h gets dropped # we pay a cost for force encoding, the h gets dropped
expect(buffer).to match(/ello.*hello/) expect(buffer).to match(/ello.*hello/)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency "freedom_patches/schema_migration_details" require_dependency "freedom_patches/schema_migration_details"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "rails_helper" require "rails_helper"
describe "translate accelerator" do describe "translate accelerator" do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'cache' require 'cache'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'global_path' require 'global_path'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
RSpec.describe CategoryGuardian do RSpec.describe CategoryGuardian do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
describe UserGuardian do describe UserGuardian do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'guardian' require 'guardian'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'has_errors' require 'has_errors'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'highlight_js/highlight_js' require_dependency 'highlight_js/highlight_js'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
describe Hijack do describe Hijack do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'html_prettify' require 'html_prettify'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'html_to_markdown' require 'html_to_markdown'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'image_sizer' require 'image_sizer'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "rails_helper" require "rails_helper"
require_dependency "import/normalize" require_dependency "import/normalize"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'inline_oneboxer' require_dependency 'inline_oneboxer'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'mini_racer' require 'mini_racer'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'json_error' require_dependency 'json_error'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'letter_avatar' require 'letter_avatar'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'method_profiler' require_dependency 'method_profiler'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "rails_helper" require "rails_helper"
require_dependency "middleware/anonymous_cache" require_dependency "middleware/anonymous_cache"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "rails_helper" require "rails_helper"
require_dependency "middleware/request_tracker" require_dependency "middleware/request_tracker"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'migration/column_dropper' require_dependency 'migration/column_dropper'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'migration/safe_migrate' require_dependency 'migration/safe_migrate'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'migration/table_dropper' require_dependency 'migration/table_dropper'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'new_post_manager' require 'new_post_manager'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'new_post_result' require 'new_post_result'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'onebox/engine/flash_video_onebox' require 'onebox/engine/flash_video_onebox'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
describe Onebox::Engine::WhitelistedGenericOnebox do describe Onebox::Engine::WhitelistedGenericOnebox do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'oneboxer' require_dependency 'oneboxer'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'onpdiff' require 'onpdiff'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'pbkdf2' require 'pbkdf2'
describe Pbkdf2 do describe Pbkdf2 do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'pinned_check' require 'pinned_check'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'plain_text_to_markdown' require 'plain_text_to_markdown'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'plugin/filter_manager' require_dependency 'plugin/filter_manager'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'plugin/instance' require_dependency 'plugin/instance'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require_dependency 'plugin/metadata' require_dependency 'plugin/metadata'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
describe PostActionCreator do describe PostActionCreator do

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