Showing 47 of 62 total issues
Method pay
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def pay(email, usd, details)
require 'openssl'
OpenSSL::SSL.const_set(:VERIFY_PEER, OpenSSL::SSL::VERIFY_NONE)
gateway = ActiveMerchant::Billing::PaypalAdaptivePayment.new(
mode: 'live',
Method job
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def job(u = user, exclusive: false)
settings.jobs.gc
jid = settings.jobs.start(u.login)
log = WTS::TeeLog.new(user_log(u.login), WTS::DbLog.new(settings.pgsql, jid))
job = WTS::SafeJob.new(
Method acquire
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def acquire(login = nil)
row = if login.nil?
@pgsql.exec(
[
'SELECT address FROM asset',
Method allowed?
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def allowed?(login, amount, limits = '64/128/256')
daily_limit, weekly_limit, monthly_limit = limits.split('/')
daily_limit = Zold::Amount.new(zld: daily_limit.to_f)
weekly_limit = Zold::Amount.new(zld: weekly_limit.to_f)
monthly_limit = Zold::Amount.new(zld: monthly_limit.to_f)
Method sibit
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def sibit(log: settings.log)
api = [Sibit::Fake.new]
if ENV['RACK_ENV'] != 'test'
http = Sibit::Http.new
api = settings.toggles.get('sibit:api', 'blockchain').split(',').map do |a|
Method pay_taxes
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def pay_taxes(keygap)
raise "The user #{@user.login} is not registered yet" unless @item.exists?
raise "The account #{@user.login} is not confirmed yet" unless @user.confirmed?
if @user.fake?
@log.info('It is a fake user, won\'t pay taxes')
- 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 match
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def match(tid, wallet, prefix, details)
found = []
@pgsql.exec('SELECT * FROM callback WHERE wallet = $1 AND prefix = $2', [wallet, prefix]).each do |r|
next unless Regexp.new(r['regexp']).match?(details)
id = @pgsql.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 known?
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def known?(login = @locals[:guser])
return false unless login
return true if %w[yegor256 davvd].include?(login)
return true if ENV['RACK_ENV'] == 'test'
return true if login == settings.config['rewards']['login']
- 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
Avoid deeply nested control flow statements. Open
unless friend.item.exists?
friend.create(settings.remotes)
ops(friend).push
end
Method add
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def add(login, wallet, prefix, regexp, uri, token = 'none', repeat: false, forever: false)
Method pay_hosting_bonuses
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def pay_hosting_bonuses(boss, jid, log)
bonus = Zold::Amount.new(zld: 1.0)
ops(boss, log: log).remove
ops(boss, log: log).pull
latest = boss.wallet(&:txns).reverse.find { |t| t.amount.negative? }
- 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
Avoid deeply nested control flow statements. Open
raise WTS::UserError, "E115: Invalid GitHub user name: #{bnf.inspect}" unless login =~ /^[a-z0-9-]{3,32}$/
Avoid deeply nested control flow statements. Open
raise WTS::UserError, 'E116: You can\'t pay yourself' if login == user.login
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(item, user, wallets, remotes, copies, log: Zold::Log::NULL, network: 'test')
Method push
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def push
if @user.fake?
@log.info('It is a fake user, won\'t PUSH to the network')
return
end
- 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 kyc?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def kyc?(login = @locals[:guser])
return false unless login
return true if ENV['RACK_ENV'] == 'test'
return true if login == settings.config['rewards']['login']
return true if login == settings.config['exchange']['login']
- 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 flash
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def flash(uri, msg, error: false)
cookies[:flash_msg] = msg
cookies[:flash_color] = error ? 'firebrick' : 'seagreen'
redirect(uri, error ? 303 : 302) unless params[:noredirect]
msg
- 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 pay
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def pay(address, satoshi)
batch = {}
unspent = 0
@pgsql.exec('SELECT * FROM asset WHERE value > 0 ORDER BY value').each do |r|
next if r['pvt'].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
Function wts_recalc
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function wts_recalc() {
'use strict';
wts_info('Loading rates...')
$.ajax({
dataType: 'json',
- 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
Avoid too many return
statements within this method. Open
return true if login == settings.config['exchange']['login']