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 (s *Store) SetDelegationClaimedRewards(id sfctype.DelegationID, amount *big.Int) {
    err := s.table.DelegationOldRewards.Put(id.Bytes(), amount.Bytes())
    if err != nil {
        s.Log.Crit("Failed to put key-value", "err", err)
    }
Severity: Major
Found in app/store_rewards_history.go and 5 other locations - About 35 mins to fix
app/store_poi.go on lines 55..60
app/store_poi.go on lines 140..145
app/store_poi.go on lines 171..176
app/store_rewards_history.go on lines 23..28
app/store_rewards_history.go on lines 93..98

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

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 (s *Store) SetStakerPOI(stakerID idx.StakerID, poi *big.Int) {
    err := s.table.StakerPOIScore.Put(stakerID.Bytes(), poi.Bytes())
    if err != nil {
        s.Log.Crit("Failed to set key", "err", err)
    }
Severity: Major
Found in app/store_poi.go and 5 other locations - About 35 mins to fix
app/store_poi.go on lines 55..60
app/store_poi.go on lines 171..176
app/store_rewards_history.go on lines 23..28
app/store_rewards_history.go on lines 58..63
app/store_rewards_history.go on lines 93..98

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

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 (s *Store) SetAddressPOI(address common.Address, poi *big.Int) {
    err := s.table.AddressPOIScore.Put(address.Bytes(), poi.Bytes())
    if err != nil {
        s.Log.Crit("Failed to set key", "err", err)
    }
Severity: Major
Found in app/store_poi.go and 5 other locations - About 35 mins to fix
app/store_poi.go on lines 55..60
app/store_poi.go on lines 140..145
app/store_rewards_history.go on lines 23..28
app/store_rewards_history.go on lines 58..63
app/store_rewards_history.go on lines 93..98

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

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 (s *Store) SetStakerClaimedRewards(stakerID idx.StakerID, amount *big.Int) {
    err := s.table.StakerOldRewards.Put(stakerID.Bytes(), amount.Bytes())
    if err != nil {
        s.Log.Crit("Failed to put key-value", "err", err)
    }
Severity: Major
Found in app/store_rewards_history.go and 5 other locations - About 35 mins to fix
app/store_poi.go on lines 55..60
app/store_poi.go on lines 140..145
app/store_poi.go on lines 171..176
app/store_rewards_history.go on lines 58..63
app/store_rewards_history.go on lines 93..98

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

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

func (b *EthAPIBackend) GetOriginationScore(ctx context.Context, stakerID idx.StakerID) (*big.Int, error) {
    if !b.svc.app.HasSfcStaker(stakerID) {
        return nil, nil
    }
    return b.svc.app.GetActiveOriginationScore(stakerID), nil
Severity: Minor
Found in gossip/ethapi_backend.go and 2 other locations - About 35 mins to fix
gossip/ethapi_backend.go on lines 508..513
gossip/ethapi_backend.go on lines 524..529

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

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

func (b *EthAPIBackend) GetValidationScore(ctx context.Context, stakerID idx.StakerID) (*big.Int, error) {
    if !b.svc.app.HasSfcStaker(stakerID) {
        return nil, nil
    }
    return b.svc.app.GetActiveValidationScore(stakerID), nil
Severity: Minor
Found in gossip/ethapi_backend.go and 2 other locations - About 35 mins to fix
gossip/ethapi_backend.go on lines 516..521
gossip/ethapi_backend.go on lines 524..529

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

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 (s *Store) SetWeightedDelegationsFee(stakerID idx.StakerID, val *big.Int) {
    err := s.table.StakerDelegationsFee.Put(stakerID.Bytes(), val.Bytes())
    if err != nil {
        s.Log.Crit("Failed to set key", "err", err)
    }
Severity: Major
Found in app/store_poi.go and 5 other locations - About 35 mins to fix
app/store_poi.go on lines 140..145
app/store_poi.go on lines 171..176
app/store_rewards_history.go on lines 23..28
app/store_rewards_history.go on lines 58..63
app/store_rewards_history.go on lines 93..98

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

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) StakerMetadata(opts *bind.CallOpts, arg0 *big.Int) ([]byte, error) {
    var (
        ret0 = new([]byte)
    )
    out := ret0
Severity: Minor
Found in gossip/sfc110/contract.go and 1 other location - About 35 mins to fix
gossip/sfc202/contract.go on lines 1480..1487

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

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

func (b *EthAPIBackend) GetStakerPoI(ctx context.Context, stakerID idx.StakerID) (*big.Int, error) {
    if !b.svc.app.HasSfcStaker(stakerID) {
        return nil, nil
    }
    return b.svc.app.GetStakerPOI(stakerID), nil
Severity: Minor
Found in gossip/ethapi_backend.go and 2 other locations - About 35 mins to fix
gossip/ethapi_backend.go on lines 508..513
gossip/ethapi_backend.go on lines 516..521

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

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) Voters(arg0 common.Address) (struct {
    Weight   *big.Int
    Voted    bool
    Delegate common.Address
    Vote     *big.Int
Severity: Minor
Found in gossip/ballot/contract.go and 1 other location - About 35 mins to fix
gossip/ballot/contract.go on lines 276..283

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

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 (s *Store) SetStakerDelegationsClaimedRewards(stakerID idx.StakerID, amount *big.Int) {
    err := s.table.StakerDelegationsOldRewards.Put(stakerID.Bytes(), amount.Bytes())
    if err != nil {
        s.Log.Crit("Failed to put key-value", "err", err)
    }
Severity: Major
Found in app/store_rewards_history.go and 5 other locations - About 35 mins to fix
app/store_poi.go on lines 55..60
app/store_poi.go on lines 140..145
app/store_poi.go on lines 171..176
app/store_rewards_history.go on lines 23..28
app/store_rewards_history.go on lines 58..63

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

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) StakerMetadata(opts *bind.CallOpts, arg0 *big.Int) ([]byte, error) {
    var (
        ret0 = new([]byte)
    )
    out := ret0
Severity: Minor
Found in gossip/sfc202/contract.go and 1 other location - About 35 mins to fix
gossip/sfc110/contract.go on lines 1306..1313

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

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) Voters(arg0 common.Address) (struct {
    Weight   *big.Int
    Voted    bool
    Delegate common.Address
    Vote     *big.Int
Severity: Minor
Found in gossip/ballot/contract.go and 1 other location - About 35 mins to fix
gossip/ballot/contract.go on lines 288..295

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

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 Checker.checkInited has 5 return statements (exceeds 4 allowed).
Open

func (v *Checker) checkInited(e *inter.Event) error {
    if e.Seq <= 0 || e.Epoch <= 0 || e.Frame <= 0 || e.Lamport <= 0 {
        return ErrNotInited // it's unsigned, but check for negative in a case if type will change
    }

Severity: Major
Found in eventcheck/basiccheck/basic_check.go - About 35 mins to fix

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

    func measureDbDir() (size int64) {
        datadir, ok := dbDir.Load().(string)
        if !ok || datadir == "" || datadir == "inmemory" {
            return
        }
    Severity: Major
    Found in cmd/lachesis/metrics/metrics.go - About 35 mins to fix

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

      func checkEventsFileHeader(reader io.Reader) error {
          headerAndVersion := make([]byte, len(eventsFileHeader)+len(eventsFileVersion))
          n, err := reader.Read(headerAndVersion)
          if err != nil {
              return err
      Severity: Major
      Found in cmd/lachesis/import.go - About 35 mins to fix

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

        func (p *SyncedPool) flush(id []byte) error {
            key := []byte("flag")
        
            // drop old DBs
            for name := range p.queuedDrops {
        Severity: Major
        Found in kvdb/flushable/synced_pool.go - About 35 mins to fix

          Method StateTransition.TransitionDb has 5 return statements (exceeds 4 allowed).
          Open

          func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
              // First check this message satisfies all consensus rules before
              // applying the message. The rules include these clauses
              //
              // 1. the nonce of the message caller is correct
          Severity: Major
          Found in evmcore/state_transition.go - About 35 mins to fix

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

            func ApplyGenesis(db ethdb.Database, net *lachesis.Config) (*EvmBlock, error) {
                if net == nil {
                    return nil, ErrNoGenesis
                }
            
            
            Severity: Major
            Found in evmcore/apply_genesis.go - About 35 mins to fix

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

              func (tt *Index) fetchSync(topics [][]common.Hash) (res []*types.Log, err error) {
                  if len(topics) > MaxCount {
                      err = ErrTooManyTopics
                      return
                  }
              Severity: Major
              Found in topicsdb/search_sync.go - About 35 mins to fix
                Severity
                Category
                Status
                Source
                Language