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 pay
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def pay(amount, fee, sources, target, change, skip_utxo: [])
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"