Fantom-foundation/go-lachesis

View on GitHub

Showing 291 of 829 total issues

Method Oracle.SuggestPrice has 64 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (gpo *Oracle) SuggestPrice(ctx context.Context) (*big.Int, error) {
    head, _ := gpo.backend.HeaderByNumber(ctx, rpc.LatestBlockNumber)
    headHash := head.Hash

    // If the latest gasprice is still available, return it.
Severity: Minor
Found in gossip/gasprice/gasprice.go - About 1 hr to fix

    Method rows.Optimize has 62 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (rr *rows) Optimize() {
    
        for curr, row := range rr.rows {
        REFS:
            for iRef, ref := range row.Refs {
    Severity: Minor
    Found in inter/ascii_scheme.go - About 1 hr to fix

      Method iterator.Next has 61 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (it *iterator) Next() bool {
          it.lock.Lock()
          defer it.lock.Unlock()
      
          if it.Error() != nil {
      Severity: Minor
      Found in kvdb/flushable/flushable.go - About 1 hr to fix

        Method ProtocolManager.makeFetcher has 61 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (pm *ProtocolManager) makeFetcher(checkers *eventcheck.Checkers) (*fetcher.Fetcher, *ordering.EventBuffer) {
            // checkers
            firstCheck := func(e *inter.Event) error {
                if err := checkers.Basiccheck.Validate(e); err != nil {
                    return err
        Severity: Minor
        Found in gossip/handler.go - About 1 hr to fix

          Method TxPool.truncatePending has 61 lines of code (exceeds 50 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 1 hr to fix

            Function importFile has 60 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func importFile(srv *gossip.Service, check bool, fn string) error {
                // Watch for Ctrl-C while the import is running.
                // If a signal is received, the import will stop.
                interrupt := make(chan os.Signal, 1)
                signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM)
            Severity: Minor
            Found in cmd/lachesis/import.go - About 1 hr to fix

              Function startNode has 60 lines of code (exceeds 50 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 1 hr to fix

                Method TxPool.add has 59 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err error) {
                    // If the transaction is already known, discard it
                    hash := tx.Hash()
                    if pool.all.Get(hash) != nil {
                        log.Trace("Discarding already known transaction", "hash", hash)
                Severity: Minor
                Found in evmcore/tx_pool.go - About 1 hr to fix

                  Method Service.processEvent has 59 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (s *Service) processEvent(realEngine Consensus, e *inter.Event) error {
                      // s.engineMu is locked here
                      if s.stopped {
                          return errStopped
                      }
                  Severity: Minor
                  Found in gossip/consensus_callbacks.go - About 1 hr to fix

                    Method Emitter.createEvent has 14 return statements (exceeds 4 allowed).
                    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 1 hr to fix

                      Function writeTo has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func writeTo(parent string, t *ast.Table, w io.Writer) (err error) {
                          var fullName string
                          if parent != "" {
                              fullName = parent + "." + t.Name
                          } else {
                      Severity: Minor
                      Found in utils/toml/file.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

                      Function ApplyTransaction has 10 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          config *params.ChainConfig,
                          bc DummyChain,
                          author *common.Address,
                          gp *GasPool,
                          statedb *state.StateDB,
                      Severity: Major
                      Found in evmcore/state_processor.go - About 1 hr to fix

                        Method PublicTransactionPoolAPI.Resend has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func (s *PublicTransactionPoolAPI) Resend(ctx context.Context, sendArgs SendTxArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error) {
                            if sendArgs.Nonce == nil {
                                return common.Hash{}, fmt.Errorf("missing transaction nonce in transaction spec")
                            }
                            if err := sendArgs.setDefaults(ctx, s.b); err != nil {
                        Severity: Minor
                        Found in ethapi/api.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

                        Function filterLogs has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func filterLogs(logs []*types.Log, fromBlock, toBlock *big.Int, addresses []common.Address, topics [][]common.Hash) []*types.Log {
                            var ret []*types.Log
                        Logs:
                            for _, log := range logs {
                                if fromBlock != nil && fromBlock.Int64() >= 0 && fromBlock.Uint64() > log.BlockNumber {
                        Severity: Minor
                        Found in gossip/filters/filter.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

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

                        func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides map[common.Address]account, vmCfg vm.Config, timeout time.Duration, globalGasCap uint64) (*evmcore.ExecutionResult, error) {
                            defer func(start time.Time) { log.Debug("Executing EVM call finished", "runtime", time.Since(start)) }(time.Now())
                        
                            state, header, err := b.StateAndHeaderByNumberOrHash(ctx, blockNrOrHash)
                            if state == nil || err != nil {
                        Severity: Minor
                        Found in ethapi/api.go - About 1 hr to fix

                          Method TxPool.loop has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (pool *TxPool) loop() {
                              defer pool.wg.Done()
                          
                              var (
                                  prevPending, prevQueued, prevStales int
                          Severity: Minor
                          Found in evmcore/tx_pool.go - About 1 hr to fix

                            Method ProtocolManager.txsyncLoop has 54 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (pm *ProtocolManager) txsyncLoop() {
                                var (
                                    pending = make(map[enode.ID]*txsync)
                                    sending = false               // whether a send is active
                                    pack    = new(txsync)         // the pack that is being sent
                            Severity: Minor
                            Found in gossip/sync.go - About 1 hr to fix

                              Function NewProtocolManager has 9 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  config *Config,
                                  notifier dagNotifier,
                                  txpool txPool,
                                  engineMu *sync.RWMutex,
                                  checkers *eventcheck.Checkers,
                              Severity: Major
                              Found in gossip/handler.go - About 1 hr to fix

                                Method Index.fetchSync has 53 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func (tt *Index) fetchSync(topics [][]common.Hash) (res []*types.Log, err error) {
                                    if len(topics) > MaxCount {
                                        err = ErrTooManyTopics
                                        return
                                    }
                                Severity: Minor
                                Found in topicsdb/search_sync.go - About 1 hr to fix

                                  Method Index.fetchAsync has 53 lines of code (exceeds 50 allowed). Consider refactoring.
                                  Open

                                  func (tt *Index) fetchAsync(topics [][]common.Hash) (res []*types.Log, err error) {
                                      if len(topics) > MaxCount {
                                          err = ErrTooManyTopics
                                          return
                                      }
                                  Severity: Minor
                                  Found in topicsdb/search_async.go - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language