Showing 27 of 41 total issues
File mailanes.rb
has 922 lines of code (exceeds 250 allowed). Consider refactoring. Open
$stdout.sync = true
require 'geoplugin'
require 'get_process_mem'
require 'glogin'
Method upload
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def upload(file, source: '')
deliveries = Deliveries.new(pgsql: @pgsql)
line = 1
File.readlines(file).each do |t|
begin
- 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_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 match
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def match(body, regex, tbot, delivery: false)
body.scan(regex).each do |id, encrypted, did|
next if id.nil? || encrypted.nil?
begin
plain = id.to_i
- 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
Class Campaign
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Campaign
attr_reader :id
def initialize(id:, pgsql:, hash: {})
raise "Invalid ID: #{id} (#{id.class.name})" unless id.is_a?(Integer)
Method match
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def match(body, regex, tbot, delivery: false)
body.scan(regex).each do |id, encrypted, did|
next if id.nil? || encrypted.nil?
begin
plain = id.to_i
Method query
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.query(campaign = 0)
chistory = [
'SELECT COUNT(*) FROM delivery',
'WHERE delivery.campaign=c.id',
'AND delivery.created > NOW() - INTERVAL \'1 DAY\''
Method add
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add(email, first: '', last: '', source: '')
raise UserError, "Invalid email #{email.inspect}" unless email =~ Recipients::REGEX
recipient = Recipient.new(
id: @pgsql.exec(
'INSERT INTO recipient (list, email, first, last, source) VALUES ($1, $2, $3, $4, $5) RETURNING id',
Method absorb
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def absorb(list)
@pgsql.transaction do |t|
t.exec(
[
'DELETE FROM delivery WHERE id IN',
Method all
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def all(query: '', limit: 100, active_only: false, in_list_only: true)
q = [
'SELECT recipient.* FROM recipient',
'JOIN list ON list.id = recipient.list AND list.owner = $1',
'WHERE',
- 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 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 upload
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def upload(file, source: '')
deliveries = Deliveries.new(pgsql: @pgsql)
line = 1
File.readlines(file).each do |t|
begin
Method deactivate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def deactivate
@pgsql.exec('SELECT * FROM letter WHERE active=true').each do |r|
letter = Letter.new(id: r['id'].to_i, pgsql: @pgsql, hash: r)
next unless letter.yaml['until'] && Time.parse(letter.yaml['until']) < Time.now
letter.toggle
- 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 yaml=
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def yaml=(yaml)
@pgsql.exec('UPDATE campaign SET yaml=$1 WHERE id=$2', [YamlDoc.new(yaml).save, @id])
yml = YamlDoc.new(yaml).load
if yml['decoy']
raise UserError, 'Decoy amount must be set' if yml['decoy']['amount'].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 csv
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def csv
CSV.generate(headers: true) do |csv|
csv << [
'Email',
'First name',
- 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 initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(host, port, login, password, codec, pgsql:, log: Loog::NULL)