Method deliver_smtp
has 129 lines of code (exceeds 25 allowed). Consider refactoring. Open
def deliver_smtp(content, recipient, codec, delivery)
html = with_utm(
Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(content),
delivery
)
Method deliver_smtp
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def deliver_smtp(content, recipient, codec, delivery)
html = with_utm(
Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(content),
delivery
)
- 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
File letter.rb
has 331 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'yaml'
require 'mail'
require 'uuidtools'
require 'timeout'
require 'pg'
Class Letter
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class Letter
# When can't deliver
class CantDeliver < StandardError; end
attr_reader :id
Method cfg
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def cfg(default, *items)
result = yaml
items.each do |i|
result = result[i]
break if result.nil?
- 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 move
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def move(inc = 1)
raise "Invalid direction #{inc.inspect}" if inc != 1 && inc != -1
@pgsql.transaction do |t|
other = t.exec(
[
- 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_utm
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def with_utm(text, delivery)
text.gsub(%r{(https?://[a-zA-Z0-9%-_./&?]+)}) do |u|
r = u + (u.include?('?') ? '&' : '?')
r += 'utm_source=mailanes.com&utm_medium=email&utm_campaign='
r += delivery.nil? ? '0' : delivery.campaign.id.to_s
- 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"