Method attach
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def attach(email, asset, strip_first_line = false)
# If 'sent_to' email cannot be found, default to Dropbox email address
to = email.to.blank? ? @settings[:address] : email.to.join(", ")
cc = email.cc.blank? ? nil : email.cc.join(", ")
Method find_or_create_and_attach
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def find_or_create_and_attach(email, data)
klass = data["Type"].constantize
if data["Email"] && klass.new.respond_to?(:email)
conditions = [
- 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 default_values
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def default_values(klass, data)
data = data.dup
keyword = data.delete("Type").capitalize
defaults = {
- 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 find_or_create_and_attach
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def find_or_create_and_attach(email, data)
klass = data["Type"].constantize
if data["Email"] && klass.new.respond_to?(:email)
conditions = [
Method attach
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def attach(email, asset, strip_first_line = false)
# If 'sent_to' email cannot be found, default to Dropbox email address
to = email.to.blank? ? @settings[:address] : email.to.join(", ")
cc = email.cc.blank? ? nil : email.cc.join(", ")
- 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 with_recipients
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def with_recipients(email, _options = {})
recipients = []
recipients += email.to_addrs unless email.to.blank?
recipients += email.cc_addrs unless email.cc.blank?
- 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"