Showing 14 of 14 total issues
Method scan
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def scan(start, max: 4)
raise Error, "Invalid block hash #{start.inspect}" unless /^[0-9a-f]{64}$/.match?(start)
raise Error, "The max number must be above zero: #{max}" if max < 1
block = start
count = 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 scan
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
def scan(start, max: 4)
raise Error, "Invalid block hash #{start.inspect}" unless /^[0-9a-f]{64}$/.match?(start)
raise Error, "The max number must be above zero: #{max}" if max < 1
block = start
count = 0
Method pay
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
def pay(amount, fee, sources, target, change, skip_utxo: [])
p = price('USD')
satoshi = satoshi(amount)
builder = Bitcoin::Builder::TxBuilder.new
unspent = 0
Method pay
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def pay(amount, fee, sources, target, change, skip_utxo: [])
p = price('USD')
satoshi = satoshi(amount)
builder = Bitcoin::Builder::TxBuilder.new
unspent = 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 utxos
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def utxos(sources)
txns = []
sources.each do |hash|
json = Sibit::Json.new(http: @http, log: @log).get(
Iri.new('https://chain.api.btc.com/v3/address').append(hash).append('unspent')
- 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 first_of
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def first_of(method)
return yield @list unless @list.is_a?(Array)
errors = []
done = false
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 get
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get(address, headers: {}, accept: [200])
start = Time.now
uri = URI(address.to_s)
res = @http.client(uri).get(
"#{uri.path.empty? ? '/' : uri.path}#{uri.query ? "?#{uri.query}" : ''}",
- 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 txns
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def txns(hash)
page = 1
psize = 50
all = []
loop do
Method block
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def block(hash)
head = Sibit::Json.new(http: @http, log: @log).get(
Iri.new('https://api-r.bitcoinchain.com/v1/block').append(hash)
)[0]
raise Sibit::Error, "The block #{hash} is not found" if head.nil?
Method utxos
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def utxos(sources)
txns = []
sources.each do |hash|
json = Sibit::Json.new(http: @http, log: @log).get(
Iri.new('https://chain.api.btc.com/v3/address').append(hash).append('unspent')
Method best_of
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def best_of(method)
return yield @list unless @list.is_a?(Array)
results = []
errors = []
@list.each do |api|
- 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 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def pay(amount, fee, sources, target, change, skip_utxo: [])
Method txns
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def txns(hash)
page = 1
psize = 50
all = []
loop do
- 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 mfee
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def mfee(fee, size)
return fee.to_i if fee.is_a?(Integer)
raise Error, 'Fee should either be a String or Integer' unless fee.is_a?(String)
mul = 1
if fee.start_with?('+', '-')
- 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"