waku-org/go-waku

View on GitHub
waku/v2/protocol/metadata/waku_metadata.go

Summary

Maintainability
A
2 hrs
Test Coverage
D
61%

Method WakuMetadata.Connected has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
Open

func (wakuM *WakuMetadata) Connected(n network.Network, cc network.Conn) {
    go func() {
        defer utils.LogOnPanic()
        wakuM.log.Debug("peer connected", zap.Stringer("peer", cc.RemotePeer()))
        // Metadata verification is done only if a clusterID is specified
Severity: Minor
Found in waku/v2/protocol/metadata/waku_metadata.go - About 55 mins 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 WakuMetadata.Connected has 6 return statements (exceeds 4 allowed).
Open

func (wakuM *WakuMetadata) Connected(n network.Network, cc network.Conn) {
    go func() {
        defer utils.LogOnPanic()
        wakuM.log.Debug("peer connected", zap.Stringer("peer", cc.RemotePeer()))
        // Metadata verification is done only if a clusterID is specified
Severity: Major
Found in waku/v2/protocol/metadata/waku_metadata.go - About 40 mins to fix

    Method WakuMetadata.Request has 5 return statements (exceeds 4 allowed).
    Open

    func (wakuM *WakuMetadata) Request(ctx context.Context, peerID peer.ID) (*pb.WakuMetadataResponse, error) {
        logger := wakuM.log.With(logging.HostID("peer", peerID))
    
        stream, err := wakuM.h.NewStream(ctx, peerID, MetadataID_v1)
        if err != nil {
    Severity: Major
    Found in waku/v2/protocol/metadata/waku_metadata.go - About 35 mins to fix

      There are no issues that match your filters.

      Category
      Status