Fantom-foundation/go-lachesis

View on GitHub

Showing 829 of 829 total issues

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

    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

      Function importFile has a Cognitive Complexity of 25 (exceeds 20 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

      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.validateTx has 11 return statements (exceeds 4 allowed).
      Open

      func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
          // Reject transactions over defined size to prevent DOS attacks
          if uint64(tx.Size()) > txMaxSize {
              return ErrOversizedData
          }
      Severity: Major
      Found in evmcore/tx_pool.go - About 1 hr to fix

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

          Method ProtocolManager.makeFetcher has 11 return statements (exceeds 4 allowed).
          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: Major
          Found in gossip/handler.go - About 1 hr to fix

            Method Election.String has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
            Open

            func (el *Election) String(voters []hash.Event) string {
                if voters == nil {
                    votersM := make(map[hash.Event]bool)
                    for vid := range el.votes {
                        votersM[vid.fromRoot] = true
            Severity: Minor
            Found in poset/election/debug.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 a Cognitive Complexity of 25 (exceeds 20 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

            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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            func (d *Helper) GetParamFloat(name, sectionName string) (float64, error) {
                param, _, err := d.getKVData(name, sectionName)
                if err != nil {
                    return -1, err
                }
            Severity: Major
            Found in utils/toml/helper.go and 1 other location - About 1 hr to fix
            utils/toml/helper.go on lines 200..212

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 135.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            func (d *Helper) GetParamInt(name, sectionName string) (int64, error) {
                param, _, err := d.getKVData(name, sectionName)
                if err != nil {
                    return -1, err
                }
            Severity: Major
            Found in utils/toml/helper.go and 1 other location - About 1 hr to fix
            utils/toml/helper.go on lines 215..227

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 135.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Method SendTxArgs.setDefaults has 52 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (args *SendTxArgs) setDefaults(ctx context.Context, b Backend) error {
                if args.GasPrice == nil {
                    price, err := b.SuggestPrice(ctx)
                    if err != nil {
                        return err
            Severity: Minor
            Found in ethapi/api.go - About 1 hr to fix

              Method Emitter.isAllowedToEmit has 52 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (em *Emitter) isAllowedToEmit(e *inter.Event, selfParent *inter.EventHeaderData) bool {
                  passedTime := e.ClaimedTime.Time().Sub(em.prevEmittedTime)
                  // Slow down emitting if power is low
                  {
                      threshold := em.config.NoTxsThreshold
              Severity: Minor
              Found in gossip/emitter.go - About 1 hr to fix

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                func (s *Store) dropTable(it ethdb.Iterator, t kvdb.KeyValueStore) {
                    keys := make([][]byte, 0, 500) // don't write during iteration
                
                    for it.Next() {
                        keys = append(keys, it.Key())
                Severity: Major
                Found in gossip/store.go and 1 other location - About 1 hr to fix
                app/store.go on lines 183..196

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 134.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                func (s *Store) dropTable(it ethdb.Iterator, t kvdb.KeyValueStore) {
                    keys := make([][]byte, 0, 500) // don't write during iteration
                
                    for it.Next() {
                        keys = append(keys, it.Key())
                Severity: Major
                Found in app/store.go and 1 other location - About 1 hr to fix
                gossip/store.go on lines 224..237

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 134.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Method PublicTransactionPoolAPI.GetTransactionReceipt has 51 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error) {
                    tx, blockNumber, index, err := s.b.GetTransaction(ctx, hash)
                    if tx == nil || err != nil {
                        return nil, err
                    }
                Severity: Minor
                Found in ethapi/api.go - About 1 hr to fix

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  func (f *Fetcher) enqueue(peer string, events inter.Events, time time.Time, fetchEvents EventsRequesterFn) error {
                      // divide big batch into smaller ones
                      for start := 0; start < len(events); start += maxInjectBatch {
                          end := len(events)
                          if end > start+maxInjectBatch {
                  Severity: Major
                  Found in gossip/fetcher/fetcher.go and 1 other location - About 1 hr to fix
                  gossip/fetcher/fetcher.go on lines 183..204

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 132.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  func (f *Fetcher) Notify(peer string, hashes hash.Events, time time.Time, fetchEvents EventsRequesterFn) error {
                      // divide big batch into smaller ones
                      for start := 0; start < len(hashes); start += maxAnnounceBatch {
                          end := len(hashes)
                          if end > start+maxAnnounceBatch {
                  Severity: Major
                  Found in gossip/fetcher/fetcher.go and 1 other location - About 1 hr to fix
                  gossip/fetcher/fetcher.go on lines 251..272

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 132.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 6 locations. Consider refactoring.
                  Open

                  func (_Contract *ContractSession) WithdrawalRequests(arg0 common.Address, arg1 *big.Int) (struct {
                      StakerID   *big.Int
                      Epoch      *big.Int
                      Time       *big.Int
                      Amount     *big.Int
                  Severity: Major
                  Found in gossip/sfc110/contract.go and 5 other locations - About 1 hr to fix
                  gossip/sfc110/contract.go on lines 1565..1573
                  gossip/sfc202/contract.go on lines 1752..1760
                  gossip/sfc202/contract.go on lines 1765..1773
                  gossip/sfc204/contract.go on lines 1679..1687
                  gossip/sfc204/contract.go on lines 1692..1700

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 131.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 6 locations. Consider refactoring.
                  Open

                  func (_Contract *ContractCallerSession) WithdrawalRequests(arg0 common.Address, arg1 *big.Int) (struct {
                      StakerID   *big.Int
                      Epoch      *big.Int
                      Time       *big.Int
                      Amount     *big.Int
                  Severity: Major
                  Found in gossip/sfc110/contract.go and 5 other locations - About 1 hr to fix
                  gossip/sfc110/contract.go on lines 1552..1560
                  gossip/sfc202/contract.go on lines 1752..1760
                  gossip/sfc202/contract.go on lines 1765..1773
                  gossip/sfc204/contract.go on lines 1679..1687
                  gossip/sfc204/contract.go on lines 1692..1700

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 131.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 6 locations. Consider refactoring.
                  Open

                  func (_Contract *ContractCallerSession) WithdrawalRequests(arg0 common.Address, arg1 *big.Int) (struct {
                      StakerID   *big.Int
                      Epoch      *big.Int
                      Time       *big.Int
                      Amount     *big.Int
                  Severity: Major
                  Found in gossip/sfc202/contract.go and 5 other locations - About 1 hr to fix
                  gossip/sfc110/contract.go on lines 1552..1560
                  gossip/sfc110/contract.go on lines 1565..1573
                  gossip/sfc202/contract.go on lines 1752..1760
                  gossip/sfc204/contract.go on lines 1679..1687
                  gossip/sfc204/contract.go on lines 1692..1700

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 131.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language