Fantom-foundation/go-lachesis

View on GitHub

Showing 291 of 829 total issues

Function init has 138 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func init() {
    overrideFlags()
    overrideParams()

    // Flags for testing purpose.
Severity: Major
Found in cmd/lachesis/main.go - About 4 hrs to fix

    Method Database.meter has 137 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (db *Database) meter(refresh time.Duration) {
        // Create the counters to store current and previous compaction values
        compactions := make([][]float64, 2)
        for i := 0; i < 2; i++ {
            compactions[i] = make([]float64, 4)
    Severity: Major
    Found in kvdb/leveldb/leveldb.go - About 4 hrs to fix

      Function DoEstimateGas has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring.
      Open

      func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, gasCap uint64) (hexutil.Uint64, error) {
          // Binary search the gas requirement, as it may be higher than the amount used
          var (
              lo  uint64 = params.TxGas - 1
              hi  uint64
      Severity: Minor
      Found in ethapi/api.go - About 4 hrs 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

      Method TxPool.truncatePending has a Cognitive Complexity of 44 (exceeds 20 allowed). Consider refactoring.
      Open

      func (pool *TxPool) truncatePending() {
          pending := uint64(0)
          for _, list := range pool.pending {
              pending += uint64(list.Len())
          }
      Severity: Minor
      Found in evmcore/tx_pool.go - About 4 hrs 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

      Method serverPool.eventLoop has 121 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (pool *serverPool) eventLoop() {
          lookupCnt := 0
          var convTime mclock.AbsTime
          if pool.discSetPeriod != nil {
              pool.discSetPeriod <- time.Millisecond * 100
      Severity: Major
      Found in gossip/serverpool.go - About 3 hrs to fix

        ContractTransactorSession has 31 methods (exceeds 20 allowed). Consider refactoring.
        Open

        type ContractTransactorSession struct {
            Contract     *ContractTransactor // Generic contract transactor binding to set the session for
            TransactOpts bind.TransactOpts   // Transaction auth options to use throughout this session
        }
        Severity: Minor
        Found in gossip/sfc202/contract.go - About 3 hrs to fix

          ContractTransactor has 31 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type ContractTransactor struct {
              contract *bind.BoundContract // Generic contract wrapper for the low level calls
          }
          Severity: Minor
          Found in gossip/sfc202/contract.go - About 3 hrs to fix

            Function startNode has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
            Open

            func startNode(ctx *cli.Context, stack *node.Node) {
                debug.Memsize.Add("node", stack)
            
                // Start up the node itself
                utils.StartNode(stack)
            Severity: Minor
            Found in cmd/lachesis/main.go - About 3 hrs 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

            Method TxPool.reset has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
            Open

            func (pool *TxPool) reset(oldHead, newHead *EvmHeader) {
                // If we're reorging an old state, reinject all dropped transactions
                var reinject types.Transactions
            
                if oldHead != nil && oldHead.Hash != newHead.ParentHash {
            Severity: Minor
            Found in evmcore/tx_pool.go - About 3 hrs 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

            File ethapi_backend.go has 570 lines of code (exceeds 500 allowed). Consider refactoring.
            Open

            package gossip
            
            import (
                "context"
                "errors"
            Severity: Minor
            Found in gossip/ethapi_backend.go - About 3 hrs to fix

              File opera_export_state.go has 557 lines of code (exceeds 500 allowed). Consider refactoring.
              Open

              package main
              
              import (
                  "bytes"
                  "context"
              Severity: Minor
              Found in cmd/lachesis/opera_export_state.go - About 3 hrs to fix

                Method Fetcher.loop has 105 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (f *Fetcher) loop() {
                    defer f.wg.Done()
                    // Iterate the event fetching until a quit is requested
                    fetchTimer := time.NewTimer(0)
                    defer fetchTimer.Stop()
                Severity: Major
                Found in gossip/fetcher/fetcher.go - About 3 hrs to fix

                  ContractTransactorSession has 27 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  type ContractTransactorSession struct {
                      Contract     *ContractTransactor // Generic contract transactor binding to set the session for
                      TransactOpts bind.TransactOpts   // Transaction auth options to use throughout this session
                  }
                  Severity: Minor
                  Found in gossip/sfc204/contract.go - About 3 hrs to fix

                    ContractTransactor has 27 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    type ContractTransactor struct {
                        contract *bind.BoundContract // Generic contract wrapper for the low level calls
                    }
                    Severity: Minor
                    Found in gossip/sfc204/contract.go - About 3 hrs to fix

                      Function ForEachRandFork has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func ForEachRandFork(
                          nodes []idx.StakerID,
                          cheatersArr []idx.StakerID,
                          eventCount int,
                          parentCount int,
                      Severity: Minor
                      Found in inter/common.go - About 3 hrs 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

                      Method Emitter.createEvent has 102 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (em *Emitter) createEvent(poolTxs map[common.Address]types.Transactions) *inter.Event {
                          if em.myStakerID == 0 {
                              // not a validator
                              return nil
                          }
                      Severity: Major
                      Found in gossip/emitter.go - About 3 hrs to fix

                        ContractTransactorSession has 24 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                        type ContractTransactorSession struct {
                            Contract     *ContractTransactor // Generic contract transactor binding to set the session for
                            TransactOpts bind.TransactOpts   // Transaction auth options to use throughout this session
                        }
                        Severity: Minor
                        Found in gossip/sfc110/contract.go - About 2 hrs to fix

                          ContractTransactor has 24 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                          type ContractTransactor struct {
                              contract *bind.BoundContract // Generic contract wrapper for the low level calls
                          }
                          Severity: Minor
                          Found in gossip/sfc110/contract.go - About 2 hrs to fix

                            peer has 23 methods (exceeds 20 allowed). Consider refactoring.
                            Open

                            type peer struct {
                                id string
                            
                                *p2p.Peer
                                rw p2p.MsgReadWriter
                            Severity: Minor
                            Found in gossip/peer.go - About 2 hrs to fix

                              Method rows.String has 87 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func (rr *rows) String() string {
                                  var (
                                      res strings.Builder
                                      out = func(s string) {
                                          _, err := res.WriteString(s)
                              Severity: Major
                              Found in inter/ascii_scheme.go - About 2 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language