Fantom-foundation/go-lachesis

View on GitHub

Showing 829 of 829 total issues

Avoid deeply nested control flow statements.
Open

                    if pool.discSetPeriod != nil {
                        pool.discSetPeriod <- time.Minute
                    }
Severity: Major
Found in gossip/serverpool.go - About 45 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/sfc202/contract.go - About 45 mins to fix

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

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

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

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

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

          func convertToPrometheusMetric(name string, m interface{}) (prometheus.Collector, bool) {
              opts := prometheus.Opts{
                  Namespace: namespace,
                  Name:      prometheusDelims(name),
              }
          Severity: Major
          Found in metrics/prometheus/metrics.go - About 45 mins to fix

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

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

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

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

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

                func (_Contract *ContractSession) LockedDelegations(arg0 common.Address, arg1 *big.Int) (struct {
                    FromEpoch *big.Int
                    EndTime   *big.Int
                    Duration  *big.Int
                }, error) {
                Severity: Major
                Found in gossip/sfc204/contract.go and 3 other locations - About 45 mins to fix
                gossip/sfc202/contract.go on lines 976..982
                gossip/sfc202/contract.go on lines 987..993
                gossip/sfc204/contract.go on lines 940..946

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

                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

                            if l.Topics[0] == sfcpos.Topics.UpdatedBaseRewardPerSec && len(l.Data) >= 32 {
                                baseRewardPerSec := new(big.Int).SetBytes(l.Data[0:32])
                                constants := s.app.GetSfcConstants(epoch)
                                constants.BaseRewardPerSec = baseRewardPerSec
                                s.app.SetSfcConstants(epoch, constants)
                Severity: Minor
                Found in gossip/sfc_index.go and 1 other location - About 45 mins to fix
                gossip/sfc_index.go on lines 311..316

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

                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 (_Contract *ContractSession) CalcDelegationRewards(delegator common.Address, _fromEpoch *big.Int, maxEpochs *big.Int) (*big.Int, *big.Int, *big.Int, error) {
                    return _Contract.Contract.CalcDelegationRewards(&_Contract.CallOpts, delegator, _fromEpoch, maxEpochs)
                }
                Severity: Minor
                Found in gossip/sfc110/contract.go and 1 other location - About 45 mins to fix
                gossip/sfc110/contract.go on lines 453..455

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

                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

                            if l.Topics[0] == sfcpos.Topics.UpdatedMinGasPrice && len(l.Data) >= 32 {
                                minGasPrice := new(big.Int).SetBytes(l.Data[0:32])
                                constants := s.app.GetSfcConstants(epoch)
                                constants.MinGasPrice = minGasPrice
                                s.app.SetSfcConstants(epoch, constants)
                Severity: Minor
                Found in gossip/sfc_index.go and 1 other location - About 45 mins to fix
                gossip/sfc_index.go on lines 289..294

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

                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 (_Contract *ContractCallerSession) CalcDelegationRewards(delegator common.Address, _fromEpoch *big.Int, maxEpochs *big.Int) (*big.Int, *big.Int, *big.Int, error) {
                    return _Contract.Contract.CalcDelegationRewards(&_Contract.CallOpts, delegator, _fromEpoch, maxEpochs)
                }
                Severity: Minor
                Found in gossip/sfc110/contract.go and 1 other location - About 45 mins to fix
                gossip/sfc110/contract.go on lines 446..448

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

                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 *ContractCaller) GetValidatorRewardRatio(opts *bind.CallOpts, stakerID *big.Int) (*big.Int, error) {
                    var (
                        ret0 = new(*big.Int)
                    )
                    out := ret0
                Severity: Minor
                Found in gossip/sfc202/contract.go and 1 other location - About 45 mins to fix
                gossip/sfc204/contract.go on lines 807..814

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

                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 *ContractCaller) GetValidatorRewardRatio(opts *bind.CallOpts, stakerID *big.Int) (*big.Int, error) {
                    var (
                        ret0 = new(*big.Int)
                    )
                    out := ret0
                Severity: Minor
                Found in gossip/sfc204/contract.go and 1 other location - About 45 mins to fix
                gossip/sfc202/contract.go on lines 798..805

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

                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 (s *PublicTransactionPoolAPI) GetBlockTransactionCountByNumber(ctx context.Context, blockNr rpc.BlockNumber) *hexutil.Uint {
                    if block, _ := s.b.BlockByNumber(ctx, blockNr); block != nil {
                        n := hexutil.Uint(len(block.Transactions))
                        return &n
                    }
                Severity: Minor
                Found in ethapi/api.go and 1 other location - About 45 mins to fix
                ethapi/api.go on lines 1386..1392

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

                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 (s *PublicTransactionPoolAPI) GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint {
                    if block, _ := s.b.BlockByHash(ctx, blockHash); block != nil {
                        n := hexutil.Uint(len(block.Transactions))
                        return &n
                    }
                Severity: Minor
                Found in ethapi/api.go and 1 other location - About 45 mins to fix
                ethapi/api.go on lines 1377..1383

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

                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 *ContractCaller) SfcAddressToStakerID(opts *bind.CallOpts, sfcAddress common.Address) (*big.Int, error) {
                    var (
                        ret0 = new(*big.Int)
                    )
                    out := ret0
                Severity: Major
                Found in gossip/sfc110/contract.go and 5 other locations - About 40 mins to fix
                gossip/sfc110/contract.go on lines 838..845
                gossip/sfc202/contract.go on lines 194..201
                gossip/sfc202/contract.go on lines 772..779
                gossip/sfc204/contract.go on lines 177..184
                gossip/sfc204/contract.go on lines 781..788

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

                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 *ContractCaller) IsDelegationLockedUp(opts *bind.CallOpts, delegator common.Address, toStakerID *big.Int) (bool, error) {
                    var (
                        ret0 = new(bool)
                    )
                    out := ret0
                Severity: Minor
                Found in gossip/sfc202/contract.go and 1 other location - About 40 mins to fix
                gossip/sfc204/contract.go on lines 833..840

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

                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 *ContractCaller) IsDelegationLockedUp(opts *bind.CallOpts, delegator common.Address, toStakerID *big.Int) (bool, error) {
                    var (
                        ret0 = new(bool)
                    )
                    out := ret0
                Severity: Minor
                Found in gossip/sfc204/contract.go and 1 other location - About 40 mins to fix
                gossip/sfc202/contract.go on lines 824..831

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

                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 *ContractCaller) SfcAddressToStakerID(opts *bind.CallOpts, sfcAddress common.Address) (*big.Int, error) {
                    var (
                        ret0 = new(*big.Int)
                    )
                    out := ret0
                Severity: Major
                Found in gossip/sfc202/contract.go and 5 other locations - About 40 mins to fix
                gossip/sfc110/contract.go on lines 298..305
                gossip/sfc110/contract.go on lines 838..845
                gossip/sfc202/contract.go on lines 772..779
                gossip/sfc204/contract.go on lines 177..184
                gossip/sfc204/contract.go on lines 781..788

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

                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