waku/v2/protocol/peer_exchange/client.go
Method WakuPeerExchange.Request
has 75 lines of code (exceeds 50 allowed). Consider refactoring. Open
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
Method WakuPeerExchange.handleResponse
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (wakuPX *WakuPeerExchange) handleResponse(ctx context.Context, response *pb.PeerExchangeResponse, params *PeerExchangeRequestParameters) error {
var discoveredPeers []struct {
addrInfo peer.AddrInfo
enr *enode.Node
}
Method WakuPeerExchange.Request
has 8 return statements (exceeds 4 allowed). Open
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
Method WakuPeerExchange.Request
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
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
- Read upRead up
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
Open
func (wakuPX *WakuPeerExchange) handleResponse(ctx context.Context, response *pb.PeerExchangeResponse, params *PeerExchangeRequestParameters) error {
var discoveredPeers []struct {
addrInfo peer.AddrInfo
enr *enode.Node
}
Method WakuPeerExchange.handleResponse
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
Open
func (wakuPX *WakuPeerExchange) handleResponse(ctx context.Context, response *pb.PeerExchangeResponse, params *PeerExchangeRequestParameters) error {
var discoveredPeers []struct {
addrInfo peer.AddrInfo
enr *enode.Node
}
- Read upRead up
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"