Fantom-foundation/go-lachesis

View on GitHub

Showing 829 of 829 total issues

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

func (_Contract *ContractFilterer) FilterUpdatedBaseRewardPerSec(opts *bind.FilterOpts) (*ContractUpdatedBaseRewardPerSecIterator, error) {

    logs, sub, err := _Contract.contract.FilterLogs(opts, "UpdatedBaseRewardPerSec")
    if err != nil {
        return nil, err
Severity: Major
Found in gossip/sfc202/contract.go and 12 other locations - About 45 mins to fix
gossip/sfc110/contract.go on lines 4438..4445
gossip/sfc110/contract.go on lines 4734..4741
gossip/sfc202/contract.go on lines 4166..4173
gossip/sfc202/contract.go on lines 5359..5366
gossip/sfc202/contract.go on lines 5492..5499
gossip/sfc202/contract.go on lines 5626..5633
gossip/sfc204/contract.go on lines 4009..4016
gossip/sfc204/contract.go on lines 4906..4913
gossip/sfc204/contract.go on lines 5202..5209
gossip/sfc204/contract.go on lines 5335..5342
gossip/sfc204/contract.go on lines 5469..5476
gossip/sfcproxy/contract.go on lines 404..411

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

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 13 locations. Consider refactoring.
Open

func (_Contract *ContractFilterer) FilterNetworkUpgradeActivated(opts *bind.FilterOpts) (*ContractNetworkUpgradeActivatedIterator, error) {

    logs, sub, err := _Contract.contract.FilterLogs(opts, "NetworkUpgradeActivated")
    if err != nil {
        return nil, err
Severity: Major
Found in gossip/sfc204/contract.go and 12 other locations - About 45 mins to fix
gossip/sfc110/contract.go on lines 4438..4445
gossip/sfc110/contract.go on lines 4734..4741
gossip/sfc202/contract.go on lines 4166..4173
gossip/sfc202/contract.go on lines 5063..5070
gossip/sfc202/contract.go on lines 5359..5366
gossip/sfc202/contract.go on lines 5492..5499
gossip/sfc202/contract.go on lines 5626..5633
gossip/sfc204/contract.go on lines 4906..4913
gossip/sfc204/contract.go on lines 5202..5209
gossip/sfc204/contract.go on lines 5335..5342
gossip/sfc204/contract.go on lines 5469..5476
gossip/sfcproxy/contract.go on lines 404..411

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

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 13 locations. Consider refactoring.
Open

func (_Contract *ContractFilterer) FilterUpdatedOfflinePenaltyThreshold(opts *bind.FilterOpts) (*ContractUpdatedOfflinePenaltyThresholdIterator, error) {

    logs, sub, err := _Contract.contract.FilterLogs(opts, "UpdatedOfflinePenaltyThreshold")
    if err != nil {
        return nil, err
Severity: Major
Found in gossip/sfc204/contract.go and 12 other locations - About 45 mins to fix
gossip/sfc110/contract.go on lines 4438..4445
gossip/sfc110/contract.go on lines 4734..4741
gossip/sfc202/contract.go on lines 4166..4173
gossip/sfc202/contract.go on lines 5063..5070
gossip/sfc202/contract.go on lines 5359..5366
gossip/sfc202/contract.go on lines 5492..5499
gossip/sfc202/contract.go on lines 5626..5633
gossip/sfc204/contract.go on lines 4009..4016
gossip/sfc204/contract.go on lines 4906..4913
gossip/sfc204/contract.go on lines 5202..5209
gossip/sfc204/contract.go on lines 5335..5342
gossip/sfcproxy/contract.go on lines 404..411

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

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 13 locations. Consider refactoring.
Open

func (_Contract *ContractFilterer) FilterUpdatedGasPowerAllocationRate(opts *bind.FilterOpts) (*ContractUpdatedGasPowerAllocationRateIterator, error) {

    logs, sub, err := _Contract.contract.FilterLogs(opts, "UpdatedGasPowerAllocationRate")
    if err != nil {
        return nil, err
Severity: Major
Found in gossip/sfc202/contract.go and 12 other locations - About 45 mins to fix
gossip/sfc110/contract.go on lines 4438..4445
gossip/sfc110/contract.go on lines 4734..4741
gossip/sfc202/contract.go on lines 4166..4173
gossip/sfc202/contract.go on lines 5063..5070
gossip/sfc202/contract.go on lines 5492..5499
gossip/sfc202/contract.go on lines 5626..5633
gossip/sfc204/contract.go on lines 4009..4016
gossip/sfc204/contract.go on lines 4906..4913
gossip/sfc204/contract.go on lines 5202..5209
gossip/sfc204/contract.go on lines 5335..5342
gossip/sfc204/contract.go on lines 5469..5476
gossip/sfcproxy/contract.go on lines 404..411

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

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 13 locations. Consider refactoring.
Open

func (_Contract *ContractFilterer) FilterUpdatedOfflinePenaltyThreshold(opts *bind.FilterOpts) (*ContractUpdatedOfflinePenaltyThresholdIterator, error) {

    logs, sub, err := _Contract.contract.FilterLogs(opts, "UpdatedOfflinePenaltyThreshold")
    if err != nil {
        return nil, err
Severity: Major
Found in gossip/sfc202/contract.go and 12 other locations - About 45 mins to fix
gossip/sfc110/contract.go on lines 4438..4445
gossip/sfc110/contract.go on lines 4734..4741
gossip/sfc202/contract.go on lines 4166..4173
gossip/sfc202/contract.go on lines 5063..5070
gossip/sfc202/contract.go on lines 5359..5366
gossip/sfc202/contract.go on lines 5492..5499
gossip/sfc204/contract.go on lines 4009..4016
gossip/sfc204/contract.go on lines 4906..4913
gossip/sfc204/contract.go on lines 5202..5209
gossip/sfc204/contract.go on lines 5335..5342
gossip/sfc204/contract.go on lines 5469..5476
gossip/sfcproxy/contract.go on lines 404..411

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

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

func (it *ContractCreatedWithdrawRequestIterator) 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

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

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

        func (it *ContractCreatedStakeIterator) 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

          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

            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

            Method TxPool.add has 7 return statements (exceeds 4 allowed).
            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: Major
            Found in evmcore/tx_pool.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 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

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

                        Avoid deeply nested control flow statements.
                        Open

                                if fullRecipients < 4 {
                                    fullRecipients = 4
                                }
                        Severity: Major
                        Found in gossip/handler.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
                            Severity
                            Category
                            Status
                            Source
                            Language