Fantom-foundation/go-lachesis

View on GitHub

Showing 291 of 829 total issues

Method row.Position has 8 return statements (exceeds 4 allowed).
Open

func (r *row) Position(i int) position {
    // if left
    if i < r.Self {
        if i < r.First {
            return none
Severity: Major
Found in inter/ascii_scheme.go - About 50 mins to fix

    Function lachesisOperaMigrationMain has 8 return statements (exceeds 4 allowed).
    Open

    func lachesisOperaMigrationMain(ctx *cli.Context) error {
        if args := ctx.Args(); len(args) > 0 {
            return fmt.Errorf("invalid command: %q", args[0])
        }
    
    
    Severity: Major
    Found in cmd/lachesis/opera_migration.go - About 50 mins to fix

      Method Checker.Validate has 8 return statements (exceeds 4 allowed).
      Open

      func (v *Checker) Validate(e *inter.Event, parents []*inter.EventHeaderData) error {
          if len(e.Parents) != len(parents) {
              panic("parentscheck: expected event's parents as an argument")
          }
      
      
      Severity: Major
      Found in eventcheck/parentscheck/parents_check.go - About 50 mins to fix

        Function importFile has 8 return statements (exceeds 4 allowed).
        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: Major
        Found in cmd/lachesis/import.go - About 50 mins to fix

          Method Emitter.isSynced has 8 return statements (exceeds 4 allowed).
          Open

          func (em *Emitter) isSynced() (bool, string, time.Duration) {
              if em.intervals.SelfForkProtection == 0 {
                  return true, "", 0 // protection disabled
              }
              if em.world.PeersNum() == 0 {
          Severity: Major
          Found in gossip/emitter.go - About 50 mins to fix

            Method ContractClaimedValidatorRewardIterator.Next has 7 return statements (exceeds 4 allowed).
            Open

            func (it *ContractClaimedValidatorRewardIterator) Next() bool {
                // If the iterator failed, stop iterating
                if it.fail != nil {
                    return false
                }
            Severity: Major
            Found in gossip/sfc110/contract.go - About 45 mins to fix

              Function File has 7 return statements (exceeds 4 allowed).
              Open

              func File(src, dst string) (err error) {
                  in, err := os.Open(src)
                  if err != nil {
                      return
                  }
              Severity: Major
              Found in utils/iocopy/file.go - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if createdTime <= stats.End {
                                        createdEpoch = e
                                        break
                                    }
                Severity: Major
                Found in cmd/lachesis/opera_export_state.go - About 45 mins to fix

                  Method Index.fetchSync has a Cognitive Complexity of 23 (exceeds 20 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 45 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

                  Method PrivateAccountAPI.SignTransaction has 7 return statements (exceeds 4 allowed).
                  Open

                  func (s *PrivateAccountAPI) SignTransaction(ctx context.Context, args SendTxArgs, passwd string) (*SignTransactionResult, error) {
                      // No need to obtain the noncelock mutex, since we won't be sending this
                      // tx into the transaction pool, but right back to the user
                      if args.Gas == nil {
                          return nil, fmt.Errorf("gas not specified")
                  Severity: Major
                  Found in ethapi/api.go - About 45 mins to fix

                    Function New has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    func New(path string, cache int, handles int, namespace string, close func() error, drop func()) (*Database, error) {
                    Severity: Minor
                    Found in kvdb/leveldb/leveldb.go - About 45 mins to fix

                      Method Index.fetchAsync has a Cognitive Complexity of 23 (exceeds 20 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 45 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

                      Avoid deeply nested control flow statements.
                      Open

                                          if pool.locals.contains(offenders[i]) {
                                              localGauge.Dec(int64(len(caps)))
                                          }
                      Severity: Major
                      Found in evmcore/tx_pool.go - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if err != nil {
                                                return genStore, errors.Wrap(err, "failed to get storage trie node")
                                            }
                        Severity: Major
                        Found in cmd/lachesis/opera_export_state.go - About 45 mins to fix

                          Function DoCall has 7 return statements (exceeds 4 allowed).
                          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: Major
                          Found in ethapi/api.go - About 45 mins to fix

                            Method Poset.checkAndSaveEvent has 7 return statements (exceeds 4 allowed).
                            Open

                            func (p *Poset) checkAndSaveEvent(e *inter.Event) error {
                                if e.Seq <= 1 && e.PrevEpochHash != p.PrevEpoch.Hash() {
                                    return ErrWrongEpochHash
                                }
                                if e.Seq > 1 && e.PrevEpochHash != hash.Zero {
                            Severity: Major
                            Found in poset/poset.go - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if dataIt.Leaf() || dataIt.Hash() == emptyNodeHash {
                                                      continue
                                                  }
                              Severity: Major
                              Found in cmd/lachesis/opera_export_state.go - About 45 mins to fix

                                Method ContractBurntRewardStashIterator.Next has 7 return statements (exceeds 4 allowed).
                                Open

                                func (it *ContractBurntRewardStashIterator) Next() bool {
                                    // If the iterator failed, stop iterating
                                    if it.fail != nil {
                                        return false
                                    }
                                Severity: Major
                                Found in gossip/sfc110/contract.go - About 45 mins to fix

                                  Method ContractClaimedDelegationRewardIterator.Next has 7 return statements (exceeds 4 allowed).
                                  Open

                                  func (it *ContractClaimedDelegationRewardIterator) Next() bool {
                                      // If the iterator failed, stop iterating
                                      if it.fail != nil {
                                          return false
                                      }
                                  Severity: Major
                                  Found in gossip/sfc110/contract.go - About 45 mins to fix

                                    Method ContractCreatedDelegationIterator.Next has 7 return statements (exceeds 4 allowed).
                                    Open

                                    func (it *ContractCreatedDelegationIterator) Next() bool {
                                        // If the iterator failed, stop iterating
                                        if it.fail != nil {
                                            return false
                                        }
                                    Severity: Major
                                    Found in gossip/sfc110/contract.go - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language