waku-org/go-waku

View on GitHub
waku/v2/node/wakunode2.go

Summary

Maintainability
F
4 days
Test Coverage
D
60%

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

    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

      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 WakuNode.Start has 127 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (w *WakuNode) Start(ctx context.Context) error {
            connGater := peermanager.NewConnectionGater(w.opts.maxConnectionsPerIP, w.log)
        
            ctx, cancel := context.WithCancel(ctx)
            w.cancel = cancel
        Severity: Major
        Found in waku/v2/node/wakunode2.go - About 4 hrs to fix

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

          func (w *WakuNode) Start(ctx context.Context) error {
              connGater := peermanager.NewConnectionGater(w.opts.maxConnectionsPerIP, w.log)
          
              ctx, cancel := context.WithCancel(ctx)
              w.cancel = cancel
          Severity: Minor
          Found in waku/v2/node/wakunode2.go - About 3 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 WakuNode.Start has 18 return statements (exceeds 4 allowed).
          Open

          func (w *WakuNode) Start(ctx context.Context) error {
              connGater := peermanager.NewConnectionGater(w.opts.maxConnectionsPerIP, w.log)
          
              ctx, cancel := context.WithCancel(ctx)
              w.cancel = cancel
          Severity: Major
          Found in waku/v2/node/wakunode2.go - About 1 hr to fix

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

            func (w *WakuNode) findRelayNodes(ctx context.Context) {
                defer utils.LogOnPanic()
                defer w.wg.Done()
            
                // Feed peers more often right after the bootstrap, then backoff
            Severity: Minor
            Found in waku/v2/node/wakunode2.go - About 1 hr 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 New has 13 return statements (exceeds 4 allowed).
            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 1 hr to fix

              Method WakuNode.findRelayNodes has 54 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (w *WakuNode) findRelayNodes(ctx context.Context) {
                  defer utils.LogOnPanic()
                  defer w.wg.Done()
              
                  // Feed peers more often right after the bootstrap, then backoff
              Severity: Minor
              Found in waku/v2/node/wakunode2.go - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                                    if prevNodeVal == "" {
                                        w.log.Info("local node enr record", logging.ENode("enr", w.localNode.Node()))
                                    } else {
                                        w.log.Info("local node new enr record", logging.ENode("enr", w.localNode.Node()))
                                    }
                Severity: Major
                Found in waku/v2/node/wakunode2.go - About 45 mins to fix

                  Method WakuNode.AddDiscoveredPeer has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  func (w *WakuNode) AddDiscoveredPeer(ID peer.ID, addrs []ma.Multiaddr, origin wps.Origin, pubsubTopics []string, enr *enode.Node, connectNow bool) {
                  Severity: Minor
                  Found in waku/v2/node/wakunode2.go - About 45 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status