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
class AllowUserLocaleEnabledValidator
def initialize(opts = {})

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_dependency "spam_handler"
class AllowedIpAddressValidator < ActiveModel::EachValidator

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'validators/reply_by_email_address_validator'
class AlternativeReplyByEmailAddressesValidator

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class CategorySearchPriorityWeightsValidator
def initialize(opts = {})
@name = opts[:name].to_s

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class CensoredWordsValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
if WordWatcher.words_for_action(:censor).present? && (censored_words = censor_words(value, censored_words_regexp)).present?

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ColorListValidator
def initialize(opts = {})
@opts = opts

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class EmailSettingValidator
def initialize(opts = {})
@opts = opts

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class EmailValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class EnableInviteOnlyValidator
def initialize(opts = {})
@opts = opts

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class EnableLocalLoginsViaEmailValidator
def initialize(opts = {})
@opts = opts

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class EnablePrivateEmailMessagesValidator
def initialize(opts = {})

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class EnableSsoValidator
def initialize(opts = {})
@opts = opts

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ExternalSystemAvatarsValidator
def initialize(opts = {})
@opts = opts

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class GroupSettingValidator
def initialize(opts = {})

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class IntegerSettingValidator
def initialize(opts = {})
@opts = opts

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Allows unique IP address (10.0.1.20), and IP addresses with a mask (10.0.0.0/8).
# Useful when storing in a Postgresql inet column.
class IpAddressFormatValidator < ActiveModel::EachValidator

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class MaxEmojisValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class MaxUsernameLengthValidator
def initialize(opts = {})
@opts = opts

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class MinUsernameLengthValidator
def initialize(opts = {})
@opts = opts

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_dependency "common_passwords/common_passwords"
class PasswordValidator < ActiveModel::EachValidator

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "net/pop"
class POP3PollingEnabledSettingValidator

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_dependency 'validators/stripped_length_validator'
module Validators; end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'text_sentinel'
require 'text_cleaner'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class RegexPresenceValidator
include RegexSettingValidation

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module RegexSettingValidation
def initialize_regex_opts(opts = {})

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class RegexSettingValidator
LOREM = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam eget sem non elit tincidunt rhoncus.'.freeze

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ReplyByEmailEnabledValidator
def initialize(opts = {})

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class SsoOverridesEmailValidator
def initialize(opts = {})
@opts = opts

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class StringSettingValidator
include RegexSettingValidation

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Validators; end
class Validators::StrippedLengthValidator < ActiveModel::EachValidator
def self.validate(record, attribute, value, range)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class TopicTitleLengthValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class UnicodeUsernameValidator
def initialize(opts = {})
@opts = opts

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class UnicodeUsernameWhitelistValidator
def initialize(opts = {})
@opts = opts

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class UniqueAmongValidator < ActiveRecord::Validations::UniquenessValidator
def validate_each(record, attribute, value)
old_errors = record.errors[attribute].size

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_dependency "file_helper"
module Validators; end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class UrlValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
if value.present?

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class UserFullNameValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class UsernameSettingValidator
include RegexSettingValidation