Fantom-foundation/go-lachesis

View on GitHub

Showing 829 of 829 total issues

Method ProtocolManager.handleMsg has 233 lines of code (exceeds 50 allowed). Consider refactoring.
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 day to fix

    Method serverPool.eventLoop has a Cognitive Complexity of 68 (exceeds 20 allowed). Consider refactoring.
    Open

    func (pool *serverPool) eventLoop() {
        lookupCnt := 0
        var convTime mclock.AbsTime
        if pool.discSetPeriod != nil {
            pool.discSetPeriod <- time.Millisecond * 100
    Severity: Minor
    Found in gossip/serverpool.go - About 1 day 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

    File handler.go has 740 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package gossip
    
    import (
        "fmt"
        "math"
    Severity: Minor
    Found in gossip/handler.go - About 7 hrs to fix

      Method Database.meter has a Cognitive Complexity of 63 (exceeds 20 allowed). Consider refactoring.
      Open

      func (db *Database) meter(refresh time.Duration) {
          // Create the counters to store current and previous compaction values
          compactions := make([][]float64, 2)
          for i := 0; i < 2; i++ {
              compactions[i] = make([]float64, 4)
      Severity: Minor
      Found in kvdb/leveldb/leveldb.go - About 7 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

      ContractCallerSession has 52 methods (exceeds 20 allowed). Consider refactoring.
      Open

      type ContractCallerSession struct {
          Contract *ContractCaller // Generic contract caller binding to set the session for
          CallOpts bind.CallOpts   // Call options to use throughout this session
      }
      Severity: Major
      Found in gossip/sfc202/contract.go - About 7 hrs to fix

        ContractCaller has 52 methods (exceeds 20 allowed). Consider refactoring.
        Open

        type ContractCaller struct {
            contract *bind.BoundContract // Generic contract wrapper for the low level calls
        }
        Severity: Major
        Found in gossip/sfc202/contract.go - About 7 hrs to fix

          ContractCaller has 51 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type ContractCaller struct {
              contract *bind.BoundContract // Generic contract wrapper for the low level calls
          }
          Severity: Major
          Found in gossip/sfc204/contract.go - About 7 hrs to fix

            ContractCallerSession has 51 methods (exceeds 20 allowed). Consider refactoring.
            Open

            type ContractCallerSession struct {
                Contract *ContractCaller // Generic contract caller binding to set the session for
                CallOpts bind.CallOpts   // Call options to use throughout this session
            }
            Severity: Major
            Found in gossip/sfc204/contract.go - About 7 hrs to fix

              Method FilterCriteria.UnmarshalJSON has a Cognitive Complexity of 60 (exceeds 20 allowed). Consider refactoring.
              Open

              func (args *FilterCriteria) UnmarshalJSON(data []byte) error {
                  type input struct {
                      BlockHash *common.Hash     `json:"blockHash"`
                      FromBlock *rpc.BlockNumber `json:"fromBlock"`
                      ToBlock   *rpc.BlockNumber `json:"toBlock"`
              Severity: Minor
              Found in gossip/filters/api.go - About 6 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

              ContractCallerSession has 47 methods (exceeds 20 allowed). Consider refactoring.
              Open

              type ContractCallerSession struct {
                  Contract *ContractCaller // Generic contract caller binding to set the session for
                  CallOpts bind.CallOpts   // Call options to use throughout this session
              }
              Severity: Minor
              Found in gossip/sfc110/contract.go - About 6 hrs to fix

                ContractCaller has 47 methods (exceeds 20 allowed). Consider refactoring.
                Open

                type ContractCaller struct {
                    contract *bind.BoundContract // Generic contract wrapper for the low level calls
                }
                Severity: Minor
                Found in gossip/sfc110/contract.go - About 6 hrs to fix

                  File serverpool.go has 678 lines of code (exceeds 500 allowed). Consider refactoring.
                  Open

                  package gossip
                  
                  import (
                      "crypto/ecdsa"
                      "fmt"
                  Severity: Minor
                  Found in gossip/serverpool.go - About 6 hrs to fix

                    Method Index.fillEventVectors has a Cognitive Complexity of 56 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (vi *Index) fillEventVectors(e *inter.EventHeaderData) allVecs {
                        meIdx := vi.validatorIdxs[e.Creator]
                        myVecs := allVecs{
                            beforeSeq:  NewHighestBeforeSeq(len(vi.bi.BranchIDCreatorIdxs)),
                            beforeTime: NewHighestBeforeTime(len(vi.bi.BranchIDCreatorIdxs)),
                    Severity: Minor
                    Found in vector/index.go - About 6 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

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

                    func (_Contract *ContractFilterer) WatchUpdatedDelegation(opts *bind.WatchOpts, sink chan<- *ContractUpdatedDelegation, delegator []common.Address, oldStakerID []*big.Int, newStakerID []*big.Int) (event.Subscription, error) {
                    
                        var delegatorRule []interface{}
                        for _, delegatorItem := range delegator {
                            delegatorRule = append(delegatorRule, delegatorItem)
                    Severity: Major
                    Found in gossip/sfc204/contract.go and 2 other locations - About 5 hrs to fix
                    gossip/sfc110/contract.go on lines 4599..4644
                    gossip/sfc202/contract.go on lines 5224..5269

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

                    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 *ContractFilterer) WatchUpdatedDelegation(opts *bind.WatchOpts, sink chan<- *ContractUpdatedDelegation, delegator []common.Address, oldStakerID []*big.Int, newStakerID []*big.Int) (event.Subscription, error) {
                    
                        var delegatorRule []interface{}
                        for _, delegatorItem := range delegator {
                            delegatorRule = append(delegatorRule, delegatorItem)
                    Severity: Major
                    Found in gossip/sfc110/contract.go and 2 other locations - About 5 hrs to fix
                    gossip/sfc202/contract.go on lines 5224..5269
                    gossip/sfc204/contract.go on lines 5067..5112

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

                    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 *ContractFilterer) WatchUpdatedDelegation(opts *bind.WatchOpts, sink chan<- *ContractUpdatedDelegation, delegator []common.Address, oldStakerID []*big.Int, newStakerID []*big.Int) (event.Subscription, error) {
                    
                        var delegatorRule []interface{}
                        for _, delegatorItem := range delegator {
                            delegatorRule = append(delegatorRule, delegatorItem)
                    Severity: Major
                    Found in gossip/sfc202/contract.go and 2 other locations - About 5 hrs to fix
                    gossip/sfc110/contract.go on lines 4599..4644
                    gossip/sfc204/contract.go on lines 5067..5112

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

                    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 *ContractFilterer) WatchPartialWithdrawnByRequest(opts *bind.WatchOpts, sink chan<- *ContractPartialWithdrawnByRequest, auth []common.Address, receiver []common.Address, stakerID []*big.Int) (event.Subscription, error) {
                    
                        var authRule []interface{}
                        for _, authItem := range auth {
                            authRule = append(authRule, authItem)
                    Severity: Major
                    Found in gossip/sfc202/contract.go and 5 other locations - About 5 hrs to fix
                    gossip/sfc110/contract.go on lines 2946..2991
                    gossip/sfc110/contract.go on lines 3856..3901
                    gossip/sfc202/contract.go on lines 3139..3184
                    gossip/sfc204/contract.go on lines 2982..3027
                    gossip/sfc204/contract.go on lines 4324..4369

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

                    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 *ContractFilterer) WatchCreatedWithdrawRequest(opts *bind.WatchOpts, sink chan<- *ContractCreatedWithdrawRequest, auth []common.Address, receiver []common.Address, stakerID []*big.Int) (event.Subscription, error) {
                    
                        var authRule []interface{}
                        for _, authItem := range auth {
                            authRule = append(authRule, authItem)
                    Severity: Major
                    Found in gossip/sfc202/contract.go and 5 other locations - About 5 hrs to fix
                    gossip/sfc110/contract.go on lines 2946..2991
                    gossip/sfc110/contract.go on lines 3856..3901
                    gossip/sfc202/contract.go on lines 4481..4526
                    gossip/sfc204/contract.go on lines 2982..3027
                    gossip/sfc204/contract.go on lines 4324..4369

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

                    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 *ContractFilterer) WatchCreatedWithdrawRequest(opts *bind.WatchOpts, sink chan<- *ContractCreatedWithdrawRequest, auth []common.Address, receiver []common.Address, stakerID []*big.Int) (event.Subscription, error) {
                    
                        var authRule []interface{}
                        for _, authItem := range auth {
                            authRule = append(authRule, authItem)
                    Severity: Major
                    Found in gossip/sfc204/contract.go and 5 other locations - About 5 hrs to fix
                    gossip/sfc110/contract.go on lines 2946..2991
                    gossip/sfc110/contract.go on lines 3856..3901
                    gossip/sfc202/contract.go on lines 3139..3184
                    gossip/sfc202/contract.go on lines 4481..4526
                    gossip/sfc204/contract.go on lines 4324..4369

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

                    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 *ContractFilterer) WatchPartialWithdrawnByRequest(opts *bind.WatchOpts, sink chan<- *ContractPartialWithdrawnByRequest, auth []common.Address, receiver []common.Address, stakerID []*big.Int) (event.Subscription, error) {
                    
                        var authRule []interface{}
                        for _, authItem := range auth {
                            authRule = append(authRule, authItem)
                    Severity: Major
                    Found in gossip/sfc204/contract.go and 5 other locations - About 5 hrs to fix
                    gossip/sfc110/contract.go on lines 2946..2991
                    gossip/sfc110/contract.go on lines 3856..3901
                    gossip/sfc202/contract.go on lines 3139..3184
                    gossip/sfc202/contract.go on lines 4481..4526
                    gossip/sfc204/contract.go on lines 2982..3027

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

                    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