waku-org/go-waku

View on GitHub

Showing 300 of 401 total issues

Method Chat.parseInput has a Cognitive Complexity of 94 (exceeds 20 allowed). Consider refactoring.
Open

func (c *Chat) parseInput() {
    defer c.wg.Done()

    var disconnectedPeers []peer.ID

Severity: Minor
Found in examples/chat2-reliable/chat.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

Function Execute has a Cognitive Complexity of 91 (exceeds 20 allowed). Consider refactoring.
Open

func Execute(options NodeOptions) error {
    // Set encoding for logs (console, json, ...)
    // Note that libp2p reads the encoding from GOLOG_LOG_FMT env var.
    lvl, err := zapcore.ParseLevel(options.LogLevel)
    if err != nil {
Severity: Minor
Found in cmd/waku/node.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

Function Execute has 285 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func Execute(options NodeOptions) error {
    // Set encoding for logs (console, json, ...)
    // Note that libp2p reads the encoding from GOLOG_LOG_FMT env var.
    lvl, err := zapcore.ParseLevel(options.LogLevel)
    if err != nil {
Severity: Major
Found in cmd/waku/node.go - About 1 day to fix

    Method Chat.parseInput has a Cognitive Complexity of 80 (exceeds 20 allowed). Consider refactoring.
    Open

    func (c *Chat) parseInput() {
        defer c.wg.Done()
        for {
            select {
            case <-c.ctx.Done():
    Severity: Minor
    Found in examples/chat2/chat.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

    Method WakuNode.startKeepAlive has a Cognitive Complexity of 79 (exceeds 20 allowed). Consider refactoring.
    Open

    func (w *WakuNode) startKeepAlive(ctx context.Context, randomPeersPingDuration time.Duration, allPeersPingDuration time.Duration) {
        defer utils.LogOnPanic()
        defer w.wg.Done()
    
        if !w.opts.enableRelay {
    Severity: Minor
    Found in waku/v2/node/keepalive.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 wakunode2.go has 781 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package node
    
    import (
        "context"
        "math/rand"
    Severity: Major
    Found in waku/v2/node/wakunode2.go - About 1 day to fix

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

      func (m *MissingMessageVerifier) fetchMessagesBatch(c chan<- *protocol.Envelope, interest criteriaInterest, batchFrom int, batchTo int, now time.Time) error {
          contentTopics := interest.contentFilter.ContentTopics.ToList()
      
          logger := m.logger.With(
              zap.Stringer("peerID", interest.peerID),
      Severity: Minor
      Found in waku/v2/api/missing/missing_messages.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

      Function getFlags has 193 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func getFlags() []cli.Flag {
          // Defaults
          options.Fleet = fleetProd
      
          testCT, err := protocol.NewContentTopic("toy-chat", "3", "mingde", "proto")
      Severity: Major
      Found in examples/chat2/flags.go - About 6 hrs to fix

        Function getFlags has 193 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func getFlags() []cli.Flag {
            // Defaults
            options.Fleet = fleetProd
        
            testCT, err := protocol.NewContentTopic("toy-chat", "3", "mingde", "proto")
        Severity: Major
        Found in examples/chat2-reliable/flags.go - About 6 hrs to fix

          Function New has a Cognitive Complexity of 51 (exceeds 20 allowed). Consider refactoring.
          Open

          func New(opts ...WakuNodeOption) (*WakuNode, error) {
              var err error
              params := new(WakuNodeParameters)
              params.libP2POpts = DefaultLibP2POptions
          
          
          Severity: Minor
          Found in waku/v2/node/wakunode2.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

          WakuNode has 40 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type WakuNode struct {
              host       host.Host
              opts       *WakuNodeParameters
              log        *zap.Logger
              timesource timesource.Timesource
          Severity: Minor
          Found in waku/v2/node/wakunode2.go - About 5 hrs to fix

            File client.go has 638 lines of code (exceeds 500 allowed). Consider refactoring.
            Open

            package filter
            
            import (
                "context"
                "encoding/hex"
            Severity: Minor
            Found in waku/v2/protocol/filter/client.go - About 5 hrs to fix

              Method HistoryRetriever.Query has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
              Open

              func (hr *HistoryRetriever) Query(
                  ctx context.Context,
                  criteria store.FilterCriteria,
                  storenodeID peer.ID,
                  pageLimit uint64,
              Severity: Minor
              Found in waku/v2/api/history/history.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

              Function getStoreParams has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
              Open

              func getStoreParams(r *http.Request) (store.Criteria, []store.RequestOption, error) {
                  var options []store.RequestOption
                  var err error
                  peerAddrStr := r.URL.Query().Get("peerAddr")
                  var m multiaddr.Multiaddr
              Severity: Minor
              Found in cmd/waku/server/rest/store.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

              File peer_manager.go has 613 lines of code (exceeds 500 allowed). Consider refactoring.
              Open

              package peermanager
              
              import (
                  "context"
                  "errors"
              Severity: Minor
              Found in waku/v2/peermanager/peer_manager.go - About 4 hrs to fix

                Function New has 141 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func New(opts ...WakuNodeOption) (*WakuNode, error) {
                    var err error
                    params := new(WakuNodeParameters)
                    params.libP2POpts = DefaultLibP2POptions
                
                
                Severity: Major
                Found in waku/v2/node/wakunode2.go - About 4 hrs to fix

                  Method HistoryRetriever.Query has 134 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (hr *HistoryRetriever) Query(
                      ctx context.Context,
                      criteria store.FilterCriteria,
                      storenodeID peer.ID,
                      pageLimit uint64,
                  Severity: Major
                  Found in waku/v2/api/history/history.go - About 4 hrs to fix

                    Function TestStoreClient has 134 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func TestStoreClient(t *testing.T) {
                        ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
                        defer cancel()
                    
                        port, err := tests.FindFreePort(t, "", 5)
                    Severity: Major
                    Found in waku/v2/protocol/store/client_test.go - About 4 hrs to fix

                      Method MessageSentCheck.Start has a Cognitive Complexity of 44 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (m *MessageSentCheck) Start() {
                          defer utils.LogOnPanic()
                          ticker := time.NewTicker(m.hashQueryInterval)
                          defer ticker.Stop()
                          for {
                      Severity: Minor
                      Found in waku/v2/api/publish/message_check.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

                      Function getLegacyStoreParams has a Cognitive Complexity of 43 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func getLegacyStoreParams(r *http.Request) (*legacy_store.Query, []legacy_store.HistoryRequestOption, error) {
                          query := &legacy_store.Query{}
                          var options []legacy_store.HistoryRequestOption
                          var err error
                          peerAddrStr := r.URL.Query().Get("peerAddr")
                      Severity: Minor
                      Found in cmd/waku/server/rest/legacy_store.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