Showing 22 of 22 total issues
Method transform
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def transform(params)
case @http_post_format
when 'raw', '', nil
message = self.class.condense(MultiMail::Message::Cloudmailin.new(Mail.new(params['message'])))
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method transform
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def transform(params)
case @http_post_format
when 'parsed', '', nil
# Mail changes `self`.
headers = self.class.multimap(JSON.load(params['message-headers']))
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method transform
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def transform(params)
case @http_post_format
when 'raw', '', nil
message = self.class.condense(MultiMail::Message::Cloudmailin.new(Mail.new(params['message'])))
Method transform
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def transform(params)
case @http_post_format
when 'parsed', '', nil
# Mail changes `self`.
headers = self.class.multimap(JSON.load(params['message-headers']))
Method parse
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def parse(raw)
case raw
when String
begin
JSON.load(raw)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method transform
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def transform(params)
# JSON is necessarily UTF-8.
JSON.load(params['mandrill_events']).select do |event|
event.fetch('event') == 'inbound'
end.map do |event|
Method parse
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse(raw)
case raw
when String
begin
JSON.load(raw)
Method deliver!
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def deliver!(mail)
message = MultiMail::Message::Postmark.new(mail).to_postmark_hash.merge(parameters)
response = Faraday.post do |request|
request.url 'https://api.postmarkapp.com/email'
Method transform
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def transform(params)
headers = Multimap.new
params['Headers'].each do |header|
headers[header['Name']] = header['Value']
end
Method deliver!
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def deliver!(mail)
message = MultiMail::Message::Mandrill.new(mail).to_mandrill_hash.merge(parameters)
api_params = {
:key => api_key,
Method to_mailgun_hash
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def to_mailgun_hash
map = Multimap.new
hash = Hash.new
%w(from subject).each do |field|
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method deliver!
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def deliver!(mail)
parameters = settings.dup
parameters.delete(:return_response)
message = MultiMail::Message::SendGrid.new(mail).to_sendgrid_hash.merge(parameters)
Method deliver!
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def deliver!(mail)
message = MultiMail::Message::Mailgun.new(mail).to_mailgun_hash.merge(parameters)
connection = Faraday.new do |conn|
conn.basic_auth 'api', api_key
Method validate_options
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def validate_options(options, raise_error_if_unrecognized = true)
keys = []
for key, value in options
unless value.nil?
keys << key
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method autoresponse?
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def autoresponse?(message)
!!(
# If any of the following headers are present and have the given value.
{
'Delivered-To' => 'Autoresponder',
Method to_mailgun_hash
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_mailgun_hash
map = Multimap.new
hash = Hash.new
%w(from subject).each do |field|
Method condense
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def condense(message)
if message.multipart? && message.parts.any?(&:multipart?)
# Get the message parts as a flat array.
result = flatten(Mail.new, message.parts.dup)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method deliver!
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def deliver!(mail)
message = MultiMail::Message::Mandrill.new(mail).to_mandrill_hash.merge(parameters)
api_params = {
:key => api_key,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method deliver!
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def deliver!(mail)
message = MultiMail::Message::Postmark.new(mail).to_postmark_hash.merge(parameters)
response = Faraday.post do |request|
request.url 'https://api.postmarkapp.com/email'
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method to_postmark_hash
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def to_postmark_hash
hash = {}
%w(from subject).each do |field|
if self[field]
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"