Fantom-foundation/go-lachesis

View on GitHub

Showing 829 of 829 total issues

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

func (_Contract *ContractCaller) CalcValidatorCompoundRewards(opts *bind.CallOpts, stakerID *big.Int, _fromEpoch *big.Int, maxEpochs *big.Int) (*big.Int, *big.Int, *big.Int, error) {
    var (
        ret0 = new(*big.Int)
        ret1 = new(*big.Int)
        ret2 = new(*big.Int)
Severity: Major
Found in gossip/sfc204/contract.go and 4 other locations - About 2 hrs to fix
gossip/sfc110/contract.go on lines 460..473
gossip/sfc202/contract.go on lines 284..297
gossip/sfc202/contract.go on lines 316..329
gossip/sfc204/contract.go on lines 325..338

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

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

func (_Contract *ContractCaller) EpochValidator(opts *bind.CallOpts, e *big.Int, v *big.Int) (struct {
    StakeAmount      *big.Int
    DelegatedMe      *big.Int
    BaseRewardWeight *big.Int
    TxRewardWeight   *big.Int
Severity: Major
Found in gossip/sfc204/contract.go and 2 other locations - About 2 hrs to fix
gossip/sfc110/contract.go on lines 794..809
gossip/sfc202/contract.go on lines 676..691

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

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 Store.MigrateMultiDelegations has 80 lines of code (exceeds 50 allowed). Consider refactoring.
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 2 hrs to fix

    Emitter has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type Emitter struct {
        txTime *lru.Cache // tx hash -> tx time
    
        net    *lachesis.Config
        config *EmitterConfig
    Severity: Minor
    Found in gossip/emitter.go - About 2 hrs to fix

      Method PeerPacksDownloader.loop has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
      Open

      func (d *PeerPacksDownloader) loop() {
          // Iterate the event fetching until a quit is requested
          syncTicker := time.NewTicker(recheckInterval)
          defer syncTicker.Stop()
      
      
      Severity: Minor
      Found in gossip/packsdownloader/peer_downloader.go - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function ForEachRandFork has 76 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func ForEachRandFork(
          nodes []idx.StakerID,
          cheatersArr []idx.StakerID,
          eventCount int,
          parentCount int,
      Severity: Major
      Found in inter/common.go - About 2 hrs to fix

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

        func (h *HandlerT) StartCPUProfile(file string) error {
            h.mu.Lock()
            defer h.mu.Unlock()
            if h.cpuW != nil {
                return errors.New("CPU profiling already in progress")
        Severity: Major
        Found in debug/api.go and 1 other location - About 2 hrs to fix
        debug/trace.go on lines 30..48

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

        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 (h *HandlerT) StartGoTrace(file string) error {
            h.mu.Lock()
            defer h.mu.Unlock()
            if h.traceW != nil {
                return errors.New("trace already in progress")
        Severity: Major
        Found in debug/trace.go and 1 other location - About 2 hrs to fix
        debug/api.go on lines 98..116

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

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

        func ExportState(path string, gdb *gossip.Store, cdb *poset.Store, net *lachesis.Config) (*genesisstore.Store, error) {
            _ = os.RemoveAll(path)
        
            err := os.MkdirAll(path, 0700)
            if err != nil {
        Severity: Major
        Found in cmd/lachesis/opera_export_state.go - About 2 hrs to fix

          Method EventHeaderData.MarshalBinary has 73 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (e *EventHeaderData) MarshalBinary() ([]byte, error) {
              isPrevEpochHashEmpty := (e.PrevEpochHash == hash.Zero)
              isTxHashEmpty := (e.TxHash == EmptyTxHash)
          
              fields64 := []uint64{
          Severity: Minor
          Found in inter/event_serializer.go - About 1 hr to fix

            Method ProtocolManager.handleMsg has 21 return statements (exceeds 4 allowed).
            Open

            func (pm *ProtocolManager) handleMsg(p *peer) error {
                // Read the next message from the remote peer, and ensure it's fully consumed
                msg, err := p.rw.ReadMsg()
                if err != nil {
                    return err
            Severity: Major
            Found in gossip/handler.go - About 1 hr to fix

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

              func (_Contract *ContractCaller) LockedDelegations(opts *bind.CallOpts, 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 1 other location - About 1 hr to fix
              gossip/sfc202/contract.go on lines 958..971

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

              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) LockedDelegations(opts *bind.CallOpts, arg0 common.Address, arg1 *big.Int) (struct {
                  FromEpoch *big.Int
                  EndTime   *big.Int
                  Duration  *big.Int
              }, error) {
              Severity: Major
              Found in gossip/sfc202/contract.go and 1 other location - About 1 hr to fix
              gossip/sfc204/contract.go on lines 911..924

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

              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 *ContractSession) Stakers(arg0 *big.Int) (struct {
                  Status           *big.Int
                  CreatedEpoch     *big.Int
                  CreatedTime      *big.Int
                  DeactivatedEpoch *big.Int
              Severity: Major
              Found in gossip/sfc204/contract.go and 5 other locations - About 1 hr to fix
              gossip/sfc110/contract.go on lines 1364..1377
              gossip/sfc110/contract.go on lines 1382..1395
              gossip/sfc202/contract.go on lines 1538..1551
              gossip/sfc202/contract.go on lines 1556..1569
              gossip/sfc204/contract.go on lines 1483..1496

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

              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 *ContractCallerSession) Stakers(arg0 *big.Int) (struct {
                  Status           *big.Int
                  CreatedEpoch     *big.Int
                  CreatedTime      *big.Int
                  DeactivatedEpoch *big.Int
              Severity: Major
              Found in gossip/sfc110/contract.go and 5 other locations - About 1 hr to fix
              gossip/sfc110/contract.go on lines 1364..1377
              gossip/sfc202/contract.go on lines 1538..1551
              gossip/sfc202/contract.go on lines 1556..1569
              gossip/sfc204/contract.go on lines 1465..1478
              gossip/sfc204/contract.go on lines 1483..1496

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

              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 *ContractCallerSession) Stakers(arg0 *big.Int) (struct {
                  Status           *big.Int
                  CreatedEpoch     *big.Int
                  CreatedTime      *big.Int
                  DeactivatedEpoch *big.Int
              Severity: Major
              Found in gossip/sfc204/contract.go and 5 other locations - About 1 hr to fix
              gossip/sfc110/contract.go on lines 1364..1377
              gossip/sfc110/contract.go on lines 1382..1395
              gossip/sfc202/contract.go on lines 1538..1551
              gossip/sfc202/contract.go on lines 1556..1569
              gossip/sfc204/contract.go on lines 1465..1478

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

              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 *ContractSession) Stakers(arg0 *big.Int) (struct {
                  Status           *big.Int
                  CreatedEpoch     *big.Int
                  CreatedTime      *big.Int
                  DeactivatedEpoch *big.Int
              Severity: Major
              Found in gossip/sfc110/contract.go and 5 other locations - About 1 hr to fix
              gossip/sfc110/contract.go on lines 1382..1395
              gossip/sfc202/contract.go on lines 1538..1551
              gossip/sfc202/contract.go on lines 1556..1569
              gossip/sfc204/contract.go on lines 1465..1478
              gossip/sfc204/contract.go on lines 1483..1496

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

              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 *ContractSession) Stakers(arg0 *big.Int) (struct {
                  Status           *big.Int
                  CreatedEpoch     *big.Int
                  CreatedTime      *big.Int
                  DeactivatedEpoch *big.Int
              Severity: Major
              Found in gossip/sfc202/contract.go and 5 other locations - About 1 hr to fix
              gossip/sfc110/contract.go on lines 1364..1377
              gossip/sfc110/contract.go on lines 1382..1395
              gossip/sfc202/contract.go on lines 1556..1569
              gossip/sfc204/contract.go on lines 1465..1478
              gossip/sfc204/contract.go on lines 1483..1496

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

              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 *ContractCallerSession) Stakers(arg0 *big.Int) (struct {
                  Status           *big.Int
                  CreatedEpoch     *big.Int
                  CreatedTime      *big.Int
                  DeactivatedEpoch *big.Int
              Severity: Major
              Found in gossip/sfc202/contract.go and 5 other locations - About 1 hr to fix
              gossip/sfc110/contract.go on lines 1364..1377
              gossip/sfc110/contract.go on lines 1382..1395
              gossip/sfc202/contract.go on lines 1538..1551
              gossip/sfc204/contract.go on lines 1465..1478
              gossip/sfc204/contract.go on lines 1483..1496

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

              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 (es *EventSystem) subscribeLogs(crit ethereum.FilterQuery, logs chan []*types.Log) *Subscription {
                  sub := &subscription{
                      id:        rpc.NewID(),
                      typ:       LogsSubscription,
                      logsCrit:  crit,
              Severity: Major
              Found in gossip/filters/filter_system.go and 2 other locations - About 1 hr to fix
              gossip/filters/filter_system.go on lines 220..233
              gossip/filters/filter_system.go on lines 254..267

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

              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