mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 14:11:16 +08:00
Make rubocop happy again.
This commit is contained in:
@ -10,23 +10,23 @@ class CensoredWordsValidator < ActiveModel::EachValidator
|
||||
|
||||
private
|
||||
|
||||
def censor_words(value, regexp)
|
||||
censored_words = value.scan(regexp)
|
||||
censored_words.flatten!
|
||||
censored_words.compact!
|
||||
censored_words.map!(&:strip)
|
||||
censored_words.select!(&:present?)
|
||||
censored_words.uniq!
|
||||
censored_words
|
||||
end
|
||||
def censor_words(value, regexp)
|
||||
censored_words = value.scan(regexp)
|
||||
censored_words.flatten!
|
||||
censored_words.compact!
|
||||
censored_words.map!(&:strip)
|
||||
censored_words.select!(&:present?)
|
||||
censored_words.uniq!
|
||||
censored_words
|
||||
end
|
||||
|
||||
def join_censored_words(censored_words)
|
||||
censored_words.map!(&:downcase)
|
||||
censored_words.uniq!
|
||||
censored_words.join(", ".freeze)
|
||||
end
|
||||
def join_censored_words(censored_words)
|
||||
censored_words.map!(&:downcase)
|
||||
censored_words.uniq!
|
||||
censored_words.join(", ".freeze)
|
||||
end
|
||||
|
||||
def censored_words_regexp
|
||||
WordWatcher.word_matcher_regexp :censor
|
||||
end
|
||||
def censored_words_regexp
|
||||
WordWatcher.word_matcher_regexp :censor
|
||||
end
|
||||
end
|
||||
|
@ -30,15 +30,15 @@ class POP3PollingEnabledSettingValidator
|
||||
|
||||
private
|
||||
|
||||
def authentication_works?
|
||||
@authentication_works ||= begin
|
||||
pop3 = Net::POP3.new(SiteSetting.pop3_polling_host, SiteSetting.pop3_polling_port)
|
||||
pop3.enable_ssl(OpenSSL::SSL::VERIFY_NONE) if SiteSetting.pop3_polling_ssl
|
||||
pop3.auth_only(SiteSetting.pop3_polling_username, SiteSetting.pop3_polling_password)
|
||||
rescue Net::POPAuthenticationError
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
def authentication_works?
|
||||
@authentication_works ||= begin
|
||||
pop3 = Net::POP3.new(SiteSetting.pop3_polling_host, SiteSetting.pop3_polling_port)
|
||||
pop3.enable_ssl(OpenSSL::SSL::VERIFY_NONE) if SiteSetting.pop3_polling_ssl
|
||||
pop3.auth_only(SiteSetting.pop3_polling_username, SiteSetting.pop3_polling_password)
|
||||
rescue Net::POPAuthenticationError
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -6,17 +6,17 @@ class TopicTitleLengthValidator < ActiveModel::EachValidator
|
||||
|
||||
private
|
||||
|
||||
def title_validator(record)
|
||||
length_range =
|
||||
if record.user.try(:admin?)
|
||||
1..SiteSetting.max_topic_title_length
|
||||
elsif record.private_message?
|
||||
SiteSetting.private_message_title_length
|
||||
else
|
||||
SiteSetting.topic_title_length
|
||||
end
|
||||
def title_validator(record)
|
||||
length_range =
|
||||
if record.user.try(:admin?)
|
||||
1..SiteSetting.max_topic_title_length
|
||||
elsif record.private_message?
|
||||
SiteSetting.private_message_title_length
|
||||
else
|
||||
SiteSetting.topic_title_length
|
||||
end
|
||||
|
||||
ActiveModel::Validations::LengthValidator.new(attributes: :title, in: length_range, allow_blank: true)
|
||||
end
|
||||
ActiveModel::Validations::LengthValidator.new(attributes: :title, in: length_range, allow_blank: true)
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user