Fantom-foundation/go-lachesis

View on GitHub

Showing 829 of 829 total issues

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

func (_Contract *ContractCaller) GetStakerID(opts *bind.CallOpts, addr 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 194..201
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

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

func (_Contract *ContractCaller) GetStakerID(opts *bind.CallOpts, addr 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 298..305
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

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/sfc204/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 194..201
gossip/sfc202/contract.go on lines 772..779
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

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

func (_Contract *ContractCaller) GetStakerID(opts *bind.CallOpts, addr common.Address) (*big.Int, error) {
    var (
        ret0 = new(*big.Int)
    )
    out := ret0
Severity: Major
Found in gossip/sfc204/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 194..201
gossip/sfc202/contract.go on lines 772..779
gossip/sfc204/contract.go on lines 177..184

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

func (_Contract *ContractSession) CalcDelegationEpochReward(stakerID *big.Int, epoch *big.Int, delegationAmount *big.Int, commission *big.Int) (*big.Int, error) {
    return _Contract.Contract.CalcDelegationEpochReward(&_Contract.CallOpts, stakerID, epoch, delegationAmount, commission)
}
Severity: Minor
Found in gossip/sfc110/contract.go and 1 other location - About 40 mins to fix
gossip/sfc110/contract.go on lines 213..215

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

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) CalcDelegationEpochReward(stakerID *big.Int, epoch *big.Int, delegationAmount *big.Int, commission *big.Int) (*big.Int, error) {
    return _Contract.Contract.CalcDelegationEpochReward(&_Contract.CallOpts, stakerID, epoch, delegationAmount, commission)
}
Severity: Minor
Found in gossip/sfc110/contract.go and 1 other location - About 40 mins to fix
gossip/sfc110/contract.go on lines 206..208

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

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 Poset.calcFrameIdx has 6 return statements (exceeds 4 allowed).
Open

func (p *Poset) calcFrameIdx(e *inter.Event, checkOnly bool) (frame idx.Frame, isRoot bool) {
    if len(e.Parents) == 0 {
        // special case for very first events in the epoch
        return 1, true
    }
Severity: Major
Found in poset/poset.go - About 40 mins to fix

    Method Checkers.Validate has 6 return statements (exceeds 4 allowed).
    Open

    func (v *Checkers) Validate(e *inter.Event, parents []*inter.EventHeaderData) error {
        if err := v.Basiccheck.Validate(e); err != nil {
            return err
        }
        if err := v.Epochcheck.Validate(e); err != nil {
    Severity: Major
    Found in eventcheck/all.go - About 40 mins to fix

      Method Election.ProcessRoot has 6 return statements (exceeds 4 allowed).
      Open

      func (el *Election) ProcessRoot(newRoot RootAndSlot) (*Res, error) {
          res, err := el.chooseAtropos()
          if err != nil || res != nil {
              return res, err
          }
      Severity: Major
      Found in poset/election/election_math.go - About 40 mins to fix

        Method Store.MigrateMultiDelegations has 6 return statements (exceeds 4 allowed).
        Open

        func (s *Store) MigrateMultiDelegations() error {
            { // migrate s.table.Delegations
                newKeys := make([][]byte, 0, 10000)
                newValues := make([][]byte, 0, 10000)
                {
        Severity: Major
        Found in app/store_migration.go - About 40 mins to fix

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

          func (v *Checker) Validate(e *inter.Event) error {
              if e.Version != 0 {
                  return ErrVersion
              }
              if err := v.checkLimits(e); err != nil {
          Severity: Major
          Found in eventcheck/basiccheck/basic_check.go - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                if e.Seq >= math.MaxInt32/2 || e.Epoch >= math.MaxInt32/2 || e.Frame >= math.MaxInt32/2 ||
                    e.Lamport >= math.MaxInt32/2 || e.GasPowerUsed >= math.MaxInt64/2 || e.GasPowerLeft.Max() >= math.MaxInt64/2 {
            Severity: Major
            Found in eventcheck/basiccheck/basic_check.go - About 40 mins to fix

              Method iterator.Next has 6 return statements (exceeds 4 allowed).
              Open

              func (it *iterator) Next() bool {
                  it.lock.Lock()
                  defer it.lock.Unlock()
              
                  if it.Error() != nil {
              Severity: Major
              Found in kvdb/flushable/flushable.go - About 40 mins to fix

                Method Migration.Exec has 6 return statements (exceeds 4 allowed).
                Open

                func (m *Migration) Exec(curr IDStore) error {
                    currID := curr.GetID()
                    myID := m.ID()
                
                    if m.veryFirst() {
                Severity: Major
                Found in utils/migration/migration.go - About 40 mins to fix

                  Method TxPool.reset has 6 return statements (exceeds 4 allowed).
                  Open

                  func (pool *TxPool) reset(oldHead, newHead *EvmHeader) {
                      // If we're reorging an old state, reinject all dropped transactions
                      var reinject types.Transactions
                  
                      if oldHead != nil && oldHead.Hash != newHead.ParentHash {
                  Severity: Major
                  Found in evmcore/tx_pool.go - About 40 mins to fix

                    Method SendTxArgs.setDefaults has 6 return statements (exceeds 4 allowed).
                    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: Major
                    Found in ethapi/api.go - About 40 mins to fix

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

                      func (v *Checker) Validate(e *inter.Event) error {
                          addrs, epoch := v.reader.GetEpochPubKeys()
                          if e.Epoch != epoch {
                              return epochcheck.ErrNotRelevant
                          }
                      Severity: Major
                      Found in eventcheck/heavycheck/heavy_check.go - About 40 mins to fix

                        Method txJournal.rotate has 6 return statements (exceeds 4 allowed).
                        Open

                        func (journal *txJournal) rotate(all map[common.Address]types.Transactions) error {
                            // Close the current journal (if any is open)
                            if journal.writer != nil {
                                if err := journal.writer.Close(); err != nil {
                                    return err
                        Severity: Major
                        Found in evmcore/tx_journal.go - About 40 mins to fix

                          Method EventSystem.SubscribeLogs has 6 return statements (exceeds 4 allowed).
                          Open

                          func (es *EventSystem) SubscribeLogs(crit ethereum.FilterQuery, logs chan []*types.Log) (*Subscription, error) {
                              var from, to rpc.BlockNumber
                              if crit.FromBlock == nil {
                                  from = rpc.LatestBlockNumber
                              } else {
                          Severity: Major
                          Found in gossip/filters/filter_system.go - About 40 mins to fix

                            Method Filter.Logs has 6 return statements (exceeds 4 allowed).
                            Open

                            func (f *Filter) Logs(ctx context.Context) ([]*types.Log, error) {
                                // If we're doing singleton block filtering, execute and return
                                if f.block != hash.Zero {
                                    header, err := f.backend.HeaderByHash(ctx, f.block)
                                    if err != nil {
                            Severity: Major
                            Found in gossip/filters/filter.go - About 40 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language