JeffDeCola/my-go-examples

View on GitHub
architectures/blockchain/bitcoin-ledger/bitcoin-ledger.go

Summary

Maintainability
A
1 hr
Test Coverage

Method txRequestMessageSignedStruct.addTransactionToPendingBlock has 51 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (trms txRequestMessageSignedStruct) addTransactionToPendingBlock(unspentOutputSlice []unspentOutputStruct, change int64) {

    // Check if first transaction in pendingBlock
    first := false
    if pendingBlock.Transactions[0].Inputs == nil {
Severity: Minor
Found in architectures/blockchain/bitcoin-ledger/bitcoin-ledger.go - About 1 hr to fix

    Function getBalance has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
    Open

    func getBalance(address string) (int64, []unspentOutputStruct) {
    
        unspentOutputMap := make(map[int64]int64)
    
        var unspentOutput unspentOutputStruct
    Severity: Minor
    Found in architectures/blockchain/bitcoin-ledger/bitcoin-ledger.go - About 55 mins to fix

    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

    2: cannot find package "github.com/sirupsen/logrus" in any of:
    Open

        log "github.com/sirupsen/logrus"

    There are no issues that match your filters.

    Category
    Status