Fantom-foundation/go-lachesis

View on GitHub

Showing 291 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

      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

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

              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

                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

                  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

                    File emitter.go has 643 lines of code (exceeds 500 allowed). Consider refactoring.
                    Open

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

                      Method rows.String has a Cognitive Complexity of 50 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (rr *rows) String() string {
                          var (
                              res strings.Builder
                              out = func(s string) {
                                  _, err := res.WriteString(s)
                      Severity: Minor
                      Found in inter/ascii_scheme.go - About 5 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

                      TxPool has 39 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      type TxPool struct {
                          config      TxPoolConfig
                          chainconfig *params.ChainConfig
                          chain       stateReader
                          gasPrice    *big.Int
                      Severity: Minor
                      Found in evmcore/tx_pool.go - About 5 hrs to fix

                        Function DAGtoASCIIscheme has a Cognitive Complexity of 49 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func DAGtoASCIIscheme(events Events) (string, error) {
                            events = events.ByParents()
                        
                            var (
                                scheme rows
                        Severity: Minor
                        Found in inter/ascii_scheme.go - About 5 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

                        Method Election.ProcessRoot has a Cognitive Complexity of 49 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func (el *Election) ProcessRoot(newRoot RootAndSlot) (*Res, error) {
                            res, err := el.chooseAtropos()
                            if err != nil || res != nil {
                                return res, err
                            }
                        Severity: Minor
                        Found in poset/election/election_math.go - About 5 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 ASCIIschemeForEach has 152 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func ASCIIschemeForEach(
                            scheme string,
                            callback ForEachEvent,
                        ) (
                            nodes []idx.StakerID,
                        Severity: Major
                        Found in inter/ascii_scheme.go - About 5 hrs to fix

                          Method iterator.Next has a Cognitive Complexity of 46 (exceeds 20 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 4 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

                          Severity
                          Category
                          Status
                          Source
                          Language