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
|
||||
|
||||
class AllowUserLocaleEnabledValidator
|
||||
|
||||
def initialize(opts = {})
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_dependency "spam_handler"
|
||||
|
||||
class AllowedIpAddressValidator < ActiveModel::EachValidator
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'validators/reply_by_email_address_validator'
|
||||
|
||||
class AlternativeReplyByEmailAddressesValidator
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CategorySearchPriorityWeightsValidator
|
||||
def initialize(opts = {})
|
||||
@name = opts[:name].to_s
|
||||
|
||||
@@ -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?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ColorListValidator
|
||||
def initialize(opts = {})
|
||||
@opts = opts
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class EmailSettingValidator
|
||||
def initialize(opts = {})
|
||||
@opts = opts
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class EmailValidator < ActiveModel::EachValidator
|
||||
|
||||
def validate_each(record, attribute, value)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class EnableInviteOnlyValidator
|
||||
def initialize(opts = {})
|
||||
@opts = opts
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class EnableLocalLoginsViaEmailValidator
|
||||
def initialize(opts = {})
|
||||
@opts = opts
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class EnablePrivateEmailMessagesValidator
|
||||
|
||||
def initialize(opts = {})
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class EnableSsoValidator
|
||||
def initialize(opts = {})
|
||||
@opts = opts
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ExternalSystemAvatarsValidator
|
||||
def initialize(opts = {})
|
||||
@opts = opts
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class GroupSettingValidator
|
||||
|
||||
def initialize(opts = {})
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class IntegerSettingValidator
|
||||
def initialize(opts = {})
|
||||
@opts = opts
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class MaxEmojisValidator < ActiveModel::EachValidator
|
||||
|
||||
def validate_each(record, attribute, value)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class MaxUsernameLengthValidator
|
||||
def initialize(opts = {})
|
||||
@opts = opts
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class MinUsernameLengthValidator
|
||||
def initialize(opts = {})
|
||||
@opts = opts
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_dependency "common_passwords/common_passwords"
|
||||
|
||||
class PasswordValidator < ActiveModel::EachValidator
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "net/pop"
|
||||
|
||||
class POP3PollingEnabledSettingValidator
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_dependency 'validators/stripped_length_validator'
|
||||
|
||||
module Validators; end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'text_sentinel'
|
||||
require 'text_cleaner'
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class RegexPresenceValidator
|
||||
include RegexSettingValidation
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module RegexSettingValidation
|
||||
|
||||
def initialize_regex_opts(opts = {})
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ReplyByEmailEnabledValidator
|
||||
|
||||
def initialize(opts = {})
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SsoOverridesEmailValidator
|
||||
def initialize(opts = {})
|
||||
@opts = opts
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class StringSettingValidator
|
||||
|
||||
include RegexSettingValidation
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Validators; end
|
||||
class Validators::StrippedLengthValidator < ActiveModel::EachValidator
|
||||
def self.validate(record, attribute, value, range)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class TopicTitleLengthValidator < ActiveModel::EachValidator
|
||||
|
||||
def validate_each(record, attribute, value)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UnicodeUsernameValidator
|
||||
def initialize(opts = {})
|
||||
@opts = opts
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UnicodeUsernameWhitelistValidator
|
||||
def initialize(opts = {})
|
||||
@opts = opts
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_dependency "file_helper"
|
||||
|
||||
module Validators; end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UrlValidator < ActiveModel::EachValidator
|
||||
def validate_each(record, attribute, value)
|
||||
if value.present?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UserFullNameValidator < ActiveModel::EachValidator
|
||||
|
||||
def validate_each(record, attribute, value)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UsernameSettingValidator
|
||||
|
||||
include RegexSettingValidation
|
||||
|
||||
Reference in New Issue
Block a user