Fantom-foundation/go-lachesis

View on GitHub

Showing 829 of 829 total issues

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

func (_Contract *ContractSession) Delegations(arg0 common.Address, arg1 *big.Int) (struct {
    CreatedEpoch     *big.Int
    CreatedTime      *big.Int
    DeactivatedEpoch *big.Int
    DeactivatedTime  *big.Int
Severity: Major
Found in gossip/sfc204/contract.go and 3 other locations - About 1 hr to fix
gossip/sfc202/contract.go on lines 530..540
gossip/sfc202/contract.go on lines 545..555
gossip/sfc204/contract.go on lines 554..564

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

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

func (_Contract *ContractCallerSession) Delegations(arg0 common.Address, arg1 *big.Int) (struct {
    CreatedEpoch     *big.Int
    CreatedTime      *big.Int
    DeactivatedEpoch *big.Int
    DeactivatedTime  *big.Int
Severity: Major
Found in gossip/sfc202/contract.go and 3 other locations - About 1 hr to fix
gossip/sfc202/contract.go on lines 530..540
gossip/sfc204/contract.go on lines 539..549
gossip/sfc204/contract.go on lines 554..564

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

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

func (_Contract *ContractCallerSession) Delegations(arg0 common.Address, arg1 *big.Int) (struct {
    CreatedEpoch     *big.Int
    CreatedTime      *big.Int
    DeactivatedEpoch *big.Int
    DeactivatedTime  *big.Int
Severity: Major
Found in gossip/sfc204/contract.go and 3 other locations - About 1 hr to fix
gossip/sfc202/contract.go on lines 530..540
gossip/sfc202/contract.go on lines 545..555
gossip/sfc204/contract.go on lines 539..549

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

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 rows.Optimize has 62 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (rr *rows) Optimize() {

    for curr, row := range rr.rows {
    REFS:
        for iRef, ref := range row.Refs {
Severity: Minor
Found in inter/ascii_scheme.go - About 1 hr to fix

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

    func (s *Store) DelSfcStaker(stakerID idx.StakerID) {
        s.mutex.Stakers.Lock()
        defer s.mutex.Stakers.Unlock()
    
        err := s.table.Stakers.Delete(stakerID.Bytes())
    Severity: Major
    Found in app/store_sfc_stakers.go and 1 other location - About 1 hr to fix
    app/store_sfc_delegators.go on lines 25..38

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

    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 *Store) DelSfcDelegation(id sfctype.DelegationID) {
        s.mutex.Delegations.Lock()
        defer s.mutex.Delegations.Unlock()
    
        err := s.table.Delegations.Delete(id.Bytes())
    Severity: Major
    Found in app/store_sfc_delegators.go and 1 other location - About 1 hr to fix
    app/store_sfc_stakers.go on lines 45..58

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

    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 TxPool.truncatePending has 61 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (pool *TxPool) truncatePending() {
        pending := uint64(0)
        for _, list := range pool.pending {
            pending += uint64(list.Len())
        }
    Severity: Minor
    Found in evmcore/tx_pool.go - About 1 hr to fix

      Method iterator.Next has 61 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

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

        Method ProtocolManager.makeFetcher has 61 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (pm *ProtocolManager) makeFetcher(checkers *eventcheck.Checkers) (*fetcher.Fetcher, *ordering.EventBuffer) {
            // checkers
            firstCheck := func(e *inter.Event) error {
                if err := checkers.Basiccheck.Validate(e); err != nil {
                    return err
        Severity: Minor
        Found in gossip/handler.go - About 1 hr to fix

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

              go func() {
                  for {
                      select {
                      case l := <-logs:
                          api.filtersMu.Lock()
          Severity: Major
          Found in gossip/filters/api.go and 1 other location - About 1 hr to fix
          gossip/filters/api.go on lines 111..127

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

          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

              go func() {
                  for {
                      select {
                      case ph := <-pendingTxs:
                          api.filtersMu.Lock()
          Severity: Major
          Found in gossip/filters/api.go and 1 other location - About 1 hr to fix
          gossip/filters/api.go on lines 298..314

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

          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

          Function startNode has 60 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func startNode(ctx *cli.Context, stack *node.Node) {
              debug.Memsize.Add("node", stack)
          
              // Start up the node itself
              utils.StartNode(stack)
          Severity: Minor
          Found in cmd/lachesis/main.go - About 1 hr to fix

            Function importFile has 60 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func importFile(srv *gossip.Service, check bool, fn string) error {
                // Watch for Ctrl-C while the import is running.
                // If a signal is received, the import will stop.
                interrupt := make(chan os.Signal, 1)
                signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM)
            Severity: Minor
            Found in cmd/lachesis/import.go - About 1 hr to fix

              Method TxPool.add has 59 lines of code (exceeds 50 allowed). Consider refactoring.
              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: Minor
              Found in evmcore/tx_pool.go - About 1 hr to fix

                Method Service.processEvent has 59 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (s *Service) processEvent(realEngine Consensus, e *inter.Event) error {
                    // s.engineMu is locked here
                    if s.stopped {
                        return errStopped
                    }
                Severity: Minor
                Found in gossip/consensus_callbacks.go - About 1 hr to fix

                  Method Emitter.createEvent has 14 return statements (exceeds 4 allowed).
                  Open

                  func (em *Emitter) createEvent(poolTxs map[common.Address]types.Transactions) *inter.Event {
                      if em.myStakerID == 0 {
                          // not a validator
                          return nil
                      }
                  Severity: Major
                  Found in gossip/emitter.go - About 1 hr to fix

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

                    func (_Contract *ContractSession) LegacyDelegations(arg0 common.Address) (struct {
                        CreatedEpoch     *big.Int
                        CreatedTime      *big.Int
                        DeactivatedEpoch *big.Int
                        DeactivatedTime  *big.Int
                    Severity: Major
                    Found in gossip/sfc202/contract.go and 3 other locations - About 1 hr to fix
                    gossip/sfc110/contract.go on lines 648..658
                    gossip/sfc110/contract.go on lines 663..673
                    gossip/sfc202/contract.go on lines 943..953

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

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

                    func (_Contract *ContractCallerSession) Delegations(arg0 common.Address) (struct {
                        CreatedEpoch     *big.Int
                        CreatedTime      *big.Int
                        DeactivatedEpoch *big.Int
                        DeactivatedTime  *big.Int
                    Severity: Major
                    Found in gossip/sfc110/contract.go and 3 other locations - About 1 hr to fix
                    gossip/sfc110/contract.go on lines 648..658
                    gossip/sfc202/contract.go on lines 928..938
                    gossip/sfc202/contract.go on lines 943..953

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

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

                    func (_Contract *ContractCallerSession) LegacyDelegations(arg0 common.Address) (struct {
                        CreatedEpoch     *big.Int
                        CreatedTime      *big.Int
                        DeactivatedEpoch *big.Int
                        DeactivatedTime  *big.Int
                    Severity: Major
                    Found in gossip/sfc202/contract.go and 3 other locations - About 1 hr to fix
                    gossip/sfc110/contract.go on lines 648..658
                    gossip/sfc110/contract.go on lines 663..673
                    gossip/sfc202/contract.go on lines 928..938

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

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

                    func (_Contract *ContractSession) Delegations(arg0 common.Address) (struct {
                        CreatedEpoch     *big.Int
                        CreatedTime      *big.Int
                        DeactivatedEpoch *big.Int
                        DeactivatedTime  *big.Int
                    Severity: Major
                    Found in gossip/sfc110/contract.go and 3 other locations - About 1 hr to fix
                    gossip/sfc110/contract.go on lines 663..673
                    gossip/sfc202/contract.go on lines 928..938
                    gossip/sfc202/contract.go on lines 943..953

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

                    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