waku-org/go-waku

View on GitHub
waku/v2/protocol/peer_exchange/client.go

Summary

Maintainability
B
6 hrs
Test Coverage
C
72%

Method WakuPeerExchange.Request has 75 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (wakuPX *WakuPeerExchange) Request(ctx context.Context, numPeers int, opts ...RequestOption) error {
    params := new(PeerExchangeRequestParameters)
    params.host = wakuPX.h
    params.log = wakuPX.log
    params.pm = wakuPX.pm
Severity: Minor
Found in waku/v2/protocol/peer_exchange/client.go - About 2 hrs to fix

    Method WakuPeerExchange.handleResponse has 60 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (wakuPX *WakuPeerExchange) handleResponse(ctx context.Context, response *pb.PeerExchangeResponse, params *PeerExchangeRequestParameters) error {
        var discoveredPeers []struct {
            addrInfo peer.AddrInfo
            enr      *enode.Node
        }
    Severity: Minor
    Found in waku/v2/protocol/peer_exchange/client.go - About 1 hr to fix

      Method WakuPeerExchange.Request has 8 return statements (exceeds 4 allowed).
      Open

      func (wakuPX *WakuPeerExchange) Request(ctx context.Context, numPeers int, opts ...RequestOption) error {
          params := new(PeerExchangeRequestParameters)
          params.host = wakuPX.h
          params.log = wakuPX.log
          params.pm = wakuPX.pm
      Severity: Major
      Found in waku/v2/protocol/peer_exchange/client.go - About 50 mins to fix

        Method WakuPeerExchange.Request has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
        Open

        func (wakuPX *WakuPeerExchange) Request(ctx context.Context, numPeers int, opts ...RequestOption) error {
            params := new(PeerExchangeRequestParameters)
            params.host = wakuPX.h
            params.log = wakuPX.log
            params.pm = wakuPX.pm
        Severity: Minor
        Found in waku/v2/protocol/peer_exchange/client.go - About 45 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 WakuPeerExchange.handleResponse has 5 return statements (exceeds 4 allowed).
        Open

        func (wakuPX *WakuPeerExchange) handleResponse(ctx context.Context, response *pb.PeerExchangeResponse, params *PeerExchangeRequestParameters) error {
            var discoveredPeers []struct {
                addrInfo peer.AddrInfo
                enr      *enode.Node
            }
        Severity: Major
        Found in waku/v2/protocol/peer_exchange/client.go - About 35 mins to fix

          Method WakuPeerExchange.handleResponse has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
          Open

          func (wakuPX *WakuPeerExchange) handleResponse(ctx context.Context, response *pb.PeerExchangeResponse, params *PeerExchangeRequestParameters) error {
              var discoveredPeers []struct {
                  addrInfo peer.AddrInfo
                  enr      *enode.Node
              }
          Severity: Minor
          Found in waku/v2/protocol/peer_exchange/client.go - About 25 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

          There are no issues that match your filters.

          Category
          Status