mirror of
https://github.com/discourse/discourse.git
synced 2026-08-12 05:55:39 -05:00
Add rubocop to our build. (#5004)
This commit is contained in:
@@ -11,12 +11,12 @@ class TextSentinel
|
||||
|
||||
ENTROPY_SCALE ||= 0.7
|
||||
|
||||
def initialize(text, opts=nil)
|
||||
def initialize(text, opts = nil)
|
||||
@opts = opts || {}
|
||||
@text = text.to_s.encode('UTF-8', invalid: :replace, undef: :replace, replace: '')
|
||||
end
|
||||
|
||||
def self.body_sentinel(text, opts={})
|
||||
def self.body_sentinel(text, opts = {})
|
||||
entropy = SiteSetting.body_min_entropy
|
||||
if opts[:private_message]
|
||||
scale_entropy = SiteSetting.min_private_message_post_length.to_f / SiteSetting.min_post_length.to_f
|
||||
@@ -41,7 +41,7 @@ class TextSentinel
|
||||
# Non-ASCII characters are weighted heavier since they contain more "information"
|
||||
def entropy
|
||||
chars = @text.to_s.strip.split('')
|
||||
@entropy ||= chars.pack('M*'*chars.size).gsub("\n",'').split('=').uniq.size
|
||||
@entropy ||= chars.pack('M*' * chars.size).gsub("\n", '').split('=').uniq.size
|
||||
end
|
||||
|
||||
def valid?
|
||||
@@ -74,7 +74,6 @@ class TextSentinel
|
||||
@opts[:max_word_length].blank? || @text.split(/\s|\/|-|\.|:/).map(&:size).max <= @opts[:max_word_length]
|
||||
end
|
||||
|
||||
|
||||
def seems_quiet?
|
||||
# We don't allow all upper case content
|
||||
SiteSetting.allow_uppercase_posts || @text == @text.mb_chars.downcase.to_s || @text != @text.mb_chars.upcase.to_s
|
||||
|
||||
Reference in New Issue
Block a user