Showing 108 of 118 total issues
Method initialize
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def initialize(file: nil, text: nil)
@body = lambda do
unless file.nil?
path = File.expand_path(file)
raise "Can't find RSA key at #{file} (#{path})" unless File.exist?(path)
- 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 13 (exceeds 5 allowed). Consider refactoring. Open
def pay(from, invoice, amount, details, opts)
unless opts.force?
raise 'The amount can\'t be zero' if amount.zero?
raise "The amount can't be negative: #{amount}" if amount.negative?
if !from.root? && from.balance < amount
- 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 update
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update(opts)
st = Time.now
seen = Set.new
capacity = []
opts['depth'].times do
Method add
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add(content, host, port, score, time: Time.now, master: false)
raise "Content can't be empty" if content.empty?
raise 'TCP port must be of type Integer' unless port.is_a?(Integer)
raise "TCP port can't be negative: #{port}" if port.negative?
raise 'Time must be of type Time' unless time.is_a?(Time)
Method start
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def start(host, port, threads: Concurrent.processor_count)
raise 'Block is required for the farm to start' unless block_given?
@log.info('Zero-threads farm won\'t score anything!') if threads.zero?
if best.empty?
@log.info("No scores found in the cache at #{@cache}")
Method metronome
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def metronome(farm, opts, host, port)
metronome = Metronome.new(@log)
if opts['no-metronome']
@log.info("Metronome hasn't been started because of --no-metronome")
return metronome
Method clean
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def clean(max: 24 * 60 * 60)
Futex.new(file, log: @log).open do
list = load
list.reject! do |s|
if s[:time] >= Time.now - max
Method propagate
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def propagate(id, _)
start = Time.now
modified = []
total = 0
network = @wallets.acq(id, &:network)
Method acq
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def acq(id, exclusive: false)
@wallets.acq(id, exclusive: exclusive) do |wallet|
return yield wallet unless exclusive
before = wallet.exists? ? File.read(wallet.path) : ''
res = yield wallet
- 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 exec
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def exec(_ = 0)
sleep(20 * 60) unless @opts['routine-immediately']
@remotes.iterate(@log) do |r|
next unless r.master?
next if r.to_mnemo == @address
- 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 elect
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def elect(opts)
scores = []
@remotes.iterate(@log, farm: @farm, threads: opts['threads']) do |r|
uri = '/'
res = r.http(uri).get
- 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 nohup
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def nohup(opts)
pid = fork do
nohup_log = NohupLog.new(opts['nohup-log'], opts['nohup-log-truncate'])
Signal.trap('HUP') do
nohup_log.print("Received HUP, ignoring...\n")
Method run
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run(args = [])
opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
o.banner = "Usage: zold fetch [ID...] [options]
Available options:"
o.bool '--ignore-score-weakness',
Method fetch
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fetch(id, cps, opts)
if @remotes.all.empty?
return if opts['quiet-if-absent']
raise "There are no remote nodes, run 'zold remote reset'"
end
Method push
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def push(id, opts)
raise "There are no remote nodes, run 'zold remote reset'" if @remotes.all.empty?
@wallets.acq(id) do |wallet|
raise "The wallet #{id} is absent at #{wallet.path}" unless wallet.exists?
end
Method create_id
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create_id(opts)
loop do
id = Id.new
return id if opts['skip-test']
found = @wallets.exists?(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 run
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def run(args = [])
opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
o.banner = "Usage: zold taxes command [options]
Available commands:
#{Rainbow('taxes pay').green} wallet
- 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 exec
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def exec(step = 0)
sleep(60) unless @opts['routine-immediately']
cmd = Zold::Remote.new(remotes: @remotes, log: @log, farm: @farm)
args = ['remote', "--network=#{Shellwords.escape(@opts['network'])}", '--ignore-ping']
score = @farm.best[0]
- 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 run
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def run(args = [])
opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
o.banner = "Usage: zold pay wallet target amount [details] [options]
Where:
'wallet' is the sender's wallet 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 initialize
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def initialize(zents: nil, zld: nil)
if !zents.nil?
raise "Integer is required, while #{zents.class} provided: #{zents}" unless zents.is_a?(Integer)
@zents = zents
elsif !zld.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"