Fixed broken .casecmp rubocop replacements and disabled cop.
This commit is contained in:
parent
e9753e2d33
commit
3a401247f5
3 changed files with 9 additions and 3 deletions
|
@ -201,3 +201,9 @@ Lint/UselessAssignment:
|
||||||
Style/ExtraSpacing:
|
Style/ExtraSpacing:
|
||||||
Description: 'Do not use unnecessary spacing.'
|
Description: 'Do not use unnecessary spacing.'
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
# Broken!!!! Generates broken code since "String".downcase == "strinG".downcase is not equals "String".casecmp("strinG") but "String".casecmp("strinG") == 0 !!!
|
||||||
|
Performance/Casecmp:
|
||||||
|
Description: 'Use `casecmp` rather than `downcase ==`.'
|
||||||
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringcasecmp-vs-stringdowncase---code'
|
||||||
|
Enabled: false
|
|
@ -193,7 +193,7 @@ class Channel::EmailParser
|
||||||
# not multipart email
|
# not multipart email
|
||||||
|
|
||||||
# text part only
|
# text part only
|
||||||
elsif !mail.mime_type || mail.mime_type.to_s == '' || mail.mime_type.to_s.casecmp('text/plain')
|
elsif !mail.mime_type || mail.mime_type.to_s == '' || mail.mime_type.to_s.casecmp('text/plain') == 0
|
||||||
data[:body] = mail.body.decoded
|
data[:body] = mail.body.decoded
|
||||||
data[:body] = Encode.conv(mail.charset, data[:body])
|
data[:body] = Encode.conv(mail.charset, data[:body])
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ class Channel::EmailParser
|
||||||
# html part only, convert to text and add it as attachment
|
# html part only, convert to text and add it as attachment
|
||||||
else
|
else
|
||||||
filename = '-no name-'
|
filename = '-no name-'
|
||||||
if mail.mime_type.to_s.casecmp('text/html')
|
if mail.mime_type.to_s.casecmp('text/html') == 0
|
||||||
filename = 'message.html'
|
filename = 'message.html'
|
||||||
data[:body] = mail.body.decoded
|
data[:body] = mail.body.decoded
|
||||||
data[:body] = Encode.conv(mail.charset, data[:body])
|
data[:body] = Encode.conv(mail.charset, data[:body])
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Encode
|
||||||
end
|
end
|
||||||
|
|
||||||
# validate already existing utf8 strings
|
# validate already existing utf8 strings
|
||||||
if charset.casecmp('utf8') || charset.casecmp('utf-8')
|
if charset.casecmp('utf8') == 0 || charset.casecmp('utf-8') == 0
|
||||||
begin
|
begin
|
||||||
|
|
||||||
# return if encoding is valid
|
# return if encoding is valid
|
||||||
|
|
Loading…
Reference in a new issue