aergoio/aergo

View on GitHub
consensus/chain/tx.go

Summary

Maintainability
B
5 hrs
Test Coverage
F
7%

Method BlockGenerator.GatherTXs has 76 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (g *BlockGenerator) GatherTXs() ([]types.Transaction, error) {
    var (
        bState = g.bState

        nCollected int
Severity: Major
Found in consensus/chain/tx.go - About 2 hrs to fix

    Method BlockGenerator.GatherTXs has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
    Open

    func (g *BlockGenerator) GatherTXs() ([]types.Transaction, error) {
        var (
            bState = g.bState
    
            nCollected int
    Severity: Minor
    Found in consensus/chain/tx.go - About 1 hr 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

    Avoid deeply nested control flow statements.
    Open

                    if logger.IsDebugEnabled() {
                        logger.Debug().Msg("stop gathering tx due to size limit")
                    }
    Severity: Major
    Found in consensus/chain/tx.go - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  } else if err != nil {
                      logger.Debug().Err(err).Int("idx", i).Stringer("hash", types.LogBase58(tx.GetHash())).Msg("skip error tx")
      
                      //FIXME handling system error (panic?)
                      // ex) gas error/nonce error skip, but other system error panic
      Severity: Major
      Found in consensus/chain/tx.go - About 45 mins to fix

        Method BlockGenerator.GatherTXs has 6 return statements (exceeds 4 allowed).
        Open

        func (g *BlockGenerator) GatherTXs() ([]types.Transaction, error) {
            var (
                bState = g.bState
        
                nCollected int
        Severity: Major
        Found in consensus/chain/tx.go - About 40 mins to fix

          There are no issues that match your filters.

          Category
          Status