Showing 27 of 41 total issues
Method exhaust
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def exhaust
@pgsql.exec('SELECT * FROM campaign WHERE active = true AND exhausted IS NOT NULL').each do |r|
campaign = Campaign.new(id: r['id'].to_i, pgsql: @pgsql, hash: r)
queue = @pgsql.exec(Pipeline.query(campaign.id)).count
next if queue.zero?
- 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 add
has a Cognitive Complexity of 7 (exceeds 5 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',
- 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 fetch
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def fetch(postman, cycles: 64)
@pgsql.exec(
'DELETE FROM delivery WHERE created < $1 AND details = $2',
[(Time.now - (60 * 60)).strftime('%Y-%m-%d %H:%M:%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"
Further reading
Method notify
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def notify(type, yaml, *msg)
return unless yaml['notify'] && yaml['notify']['telegram']
return if yaml['notify']['ignore'].is_a?(Array) && yaml['notify']['ignore'].include?(type)
chat = yaml['notify']['telegram'].to_i
return unless chat.positive?
- 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"
Further reading
Method query
has a Cognitive Complexity of 6 (exceeds 5 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\''
- 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 country
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def country(ip = request.ip)
settings.zache.get("ip_to_country:#{ip}") do
json = JSON.parse(Net::HTTP.get(URI("http://ip-api.com/json/#{ip}")))
if json['status'] == 'fail'
'??'
- 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"