Fantom-foundation/go-lachesis

View on GitHub

Showing 829 of 829 total issues

Method Store.ApplyGenesis has 5 return statements (exceeds 4 allowed).
Open

func (s *Store) ApplyGenesis(g *genesis.Genesis, genesisAtropos hash.Event, appHash common.Hash) error {
    if g == nil {
        return fmt.Errorf("genesis config shouldn't be nil")
    }
    if len(g.Alloc.Validators) == 0 {
Severity: Major
Found in poset/apply_genesis.go - About 35 mins to fix

    Method EventHeaderData.UnmarshalBinary has 5 return statements (exceeds 4 allowed).
    Open

    func (e *EventHeaderData) UnmarshalBinary(raw []byte) (err error) {
        defer func() {
            if r := recover(); r != nil {
                err = ErrInvalidEncoding
            }
    Severity: Major
    Found in inter/event_serializer.go - About 35 mins to fix

      Method PublicTransactionPoolAPI.GetTransactionReceipt has 5 return statements (exceeds 4 allowed).
      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: Major
      Found in ethapi/api.go - About 35 mins to fix

        Method Helper.AddSection has 5 return statements (exceeds 4 allowed).
        Open

        func (d *Helper) AddSection(name, after string) error {
            if name == "" {
                return nil
            }
        
        
        Severity: Major
        Found in utils/toml/helper.go - About 35 mins to fix

          Method SyncedPool.checkDbsSynced has 5 return statements (exceeds 4 allowed).
          Open

          func (p *SyncedPool) checkDbsSynced() error {
              p.Lock()
              defer p.Unlock()
          
              var (
          Severity: Major
          Found in kvdb/flushable/synced_pool.go - About 35 mins to fix

            Method txList.Filter has 5 return statements (exceeds 4 allowed).
            Open

            func (l *txList) Filter(costLimit *big.Int, gasLimit uint64) (types.Transactions, types.Transactions) {
                // If all transactions are below the threshold, short circuit
                if l.costcap.Cmp(costLimit) <= 0 && l.gascap <= gasLimit {
                    return nil, nil
                }
            Severity: Major
            Found in evmcore/tx_list.go - About 35 mins to fix

              Function parseFakeGen has 5 return statements (exceeds 4 allowed).
              Open

              func parseFakeGen(s string) (num int, vaccs genesis.VAccounts, err error) {
                  var i64 uint64
              
                  parts := strings.SplitN(s, "/", 2)
                  if len(parts) != 2 {
              Severity: Major
              Found in cmd/lachesis/fake.go - About 35 mins to fix

                Method Index.Push has 5 return statements (exceeds 4 allowed).
                Open

                func (tt *Index) Push(recs ...*types.Log) error {
                    for _, rec := range recs {
                        if len(rec.Topics) > MaxCount {
                            return ErrTooManyTopics
                        }
                Severity: Major
                Found in topicsdb/topicsdb.go - About 35 mins to fix

                  Function exportEvents has 5 return statements (exceeds 4 allowed).
                  Open

                  func exportEvents(ctx *cli.Context) error {
                      if len(ctx.Args()) < 1 {
                          utils.Fatalf("This command requires an argument.")
                      }
                  
                  
                  Severity: Major
                  Found in cmd/lachesis/export_events.go - About 35 mins to fix

                    Function writeTo has 5 return statements (exceeds 4 allowed).
                    Open

                    func writeTo(parent string, t *ast.Table, w io.Writer) (err error) {
                        var fullName string
                        if parent != "" {
                            fullName = parent + "." + t.Name
                        } else {
                    Severity: Major
                    Found in utils/toml/file.go - About 35 mins to fix

                      Method PublicTransactionPoolAPI.GetTransactionByHash has 5 return statements (exceeds 4 allowed).
                      Open

                      func (s *PublicTransactionPoolAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) (*RPCTransaction, error) {
                          // Try to return an already finalized transaction
                          tx, blockNumber, index, err := s.b.GetTransaction(ctx, hash)
                          if err != nil {
                              return nil, err
                      Severity: Major
                      Found in ethapi/api.go - About 35 mins to fix

                        Method Helper.getKVData has 5 return statements (exceeds 4 allowed).
                        Open

                        func (d *Helper) getKVData(name, sectionName string) (*ast.KeyValue, *ast.Table, error) {
                            sect, err := d.FindSection(sectionName)
                            if err != nil {
                                return nil, nil, err
                            }
                        Severity: Major
                        Found in utils/toml/helper.go - About 35 mins to fix

                          Method Emitter.maxGasPowerToUse has 5 return statements (exceeds 4 allowed).
                          Open

                          func (em *Emitter) maxGasPowerToUse(e *inter.Event) uint64 {
                              // No txs in epoch tail, because tail events are unlikely to confirm
                              {
                                  if em.isEpochTail(e) {
                                      return 0
                          Severity: Major
                          Found in gossip/emitter.go - About 35 mins to fix

                            Method PublicFilterAPI.Logs has 5 return statements (exceeds 4 allowed).
                            Open

                            func (api *PublicFilterAPI) Logs(ctx context.Context, crit FilterCriteria) (*rpc.Subscription, error) {
                                notifier, supported := rpc.NotifierFromContext(ctx)
                                if !supported {
                                    return &rpc.Subscription{}, rpc.ErrNotificationsUnsupported
                                }
                            Severity: Major
                            Found in gossip/filters/api.go - About 35 mins to fix

                              Method Emitter.isAllowedToEmit has 5 return statements (exceeds 4 allowed).
                              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: Major
                              Found in gossip/emitter.go - About 35 mins to fix

                                Method EthAPIBackend.GetFullEventID has 5 return statements (exceeds 4 allowed).
                                Open

                                func (b *EthAPIBackend) GetFullEventID(shortEventID string) (hash.Event, error) {
                                    s := strings.Split(shortEventID, ":")
                                    if len(s) == 1 {
                                        // it's a full hash
                                        return hash.HexToEventHash(shortEventID), nil
                                Severity: Major
                                Found in gossip/ethapi_backend.go - About 35 mins to fix

                                  Method Emitter.createEvent has a Cognitive Complexity of 22 (exceeds 20 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: Minor
                                  Found in gossip/emitter.go - About 35 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

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

                                  func (_Contract *ContractSession) LockedStakes(arg0 *big.Int) (struct {
                                      FromEpoch *big.Int
                                      EndTime   *big.Int
                                      Duration  *big.Int
                                  }, error) {
                                  Severity: Major
                                  Found in gossip/sfc202/contract.go and 3 other locations - About 35 mins to fix
                                  gossip/sfc202/contract.go on lines 1027..1033
                                  gossip/sfc204/contract.go on lines 969..975
                                  gossip/sfc204/contract.go on lines 980..986

                                  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 105.

                                  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 (_Contract *ContractTransactor) PrepareToWithdrawDelegationPartial(opts *bind.TransactOpts, wrID *big.Int, toStakerID *big.Int, amount *big.Int) (*types.Transaction, error) {
                                      return _Contract.contract.Transact(opts, "prepareToWithdrawDelegationPartial", wrID, toStakerID, amount)
                                  }
                                  Severity: Minor
                                  Found in gossip/sfc202/contract.go and 1 other location - About 35 mins to fix
                                  gossip/sfc204/contract.go on lines 2083..2085

                                  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 105.

                                  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 (_Contract *ContractTransactor) PrepareToWithdrawDelegationPartial(opts *bind.TransactOpts, wrID *big.Int, toStakerID *big.Int, amount *big.Int) (*types.Transaction, error) {
                                      return _Contract.contract.Transact(opts, "prepareToWithdrawDelegationPartial", wrID, toStakerID, amount)
                                  }
                                  Severity: Minor
                                  Found in gossip/sfc204/contract.go and 1 other location - About 35 mins to fix
                                  gossip/sfc202/contract.go on lines 2198..2200

                                  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 105.

                                  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