waku-org/go-waku

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

Summary

Maintainability
D
1 day
Test Coverage
F
46%

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

Method WakuNode.startKeepAlive has 105 lines of code (exceeds 50 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: Major
Found in waku/v2/node/keepalive.go - About 3 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                        if peerLen > len(relayPeers) {
                            peerLen = len(relayPeers)
                        }
    Severity: Major
    Found in waku/v2/node/keepalive.go - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                  if _, ok := meshPeersSet[p]; !ok {
                                      relayPeersSet[p] = struct{}{}
                                  }
      Severity: Major
      Found in waku/v2/node/keepalive.go - About 45 mins to fix

        There are no issues that match your filters.

        Category
        Status