JeffDeCola/my-go-examples

View on GitHub

Showing 4 of 13 total issues

Function file_pbmessage_proto_init has 71 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func file_pbmessage_proto_init() {
    if File_pbmessage_proto != nil {
        return
    }
    if !protoimpl.UnsafeEnabled {

    Function main has 55 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func main() {
    
        // GENISIS BLOCKCHAIN
        // LOAD BLOCK 0 WITH 0000 TRANSACTION
        s := "GENISIS BLOCKCHAIN / LOAD BLOCK 0 WITH 0000 TRANSACTION"
    Severity: Minor
    Found in architectures/blockchain/bitcoin-ledger/control.go - About 1 hr to fix

      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

        Severity
        Category
        Status
        Source
        Language