p2p/peermanager.go
Method peerManager.runManagePeers
has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring. Open
Open
func (pm *peerManager) runManagePeers() {
pm.logger.Info().Str("p2p_proto", p2putil.ProtocolIDsToString([]protocol.ID{p2pcommon.P2PSubAddr})).Msg("Starting p2p listening")
pm.nt.AddStreamHandler(p2pcommon.P2PSubAddr, pm.wpManager.OnInboundConn)
- 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
peerManager
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type peerManager struct {
status int32
is p2pcommon.InternalService
nt p2pcommon.NetworkTransport
hsFactory p2pcommon.HSHandlerFactory
Method peerManager.runManagePeers
has 97 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (pm *peerManager) runManagePeers() {
pm.logger.Info().Str("p2p_proto", p2putil.ProtocolIDsToString([]protocol.ID{p2pcommon.P2PSubAddr})).Msg("Starting p2p listening")
pm.nt.AddStreamHandler(p2pcommon.P2PSubAddr, pm.wpManager.OnInboundConn)
File peermanager.go
has 509 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
/* @file @copyright defined in aergo/LICENSE.txt */
package p2p
import (