aergoio/aergo

View on GitHub
p2p/peermanager.go

Summary

Maintainability
D
1 day
Test Coverage
F
48%

Method peerManager.runManagePeers has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring.
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)

Severity: Minor
Found in p2p/peermanager.go - About 4 hrs 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

peerManager has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

type peerManager struct {
    status            int32
    is                p2pcommon.InternalService
    nt                p2pcommon.NetworkTransport
    hsFactory         p2pcommon.HSHandlerFactory
Severity: Minor
Found in p2p/peermanager.go - About 3 hrs to fix

    Method peerManager.runManagePeers has 97 lines of code (exceeds 50 allowed). Consider refactoring.
    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)
    
    
    Severity: Major
    Found in p2p/peermanager.go - About 2 hrs to fix

      File peermanager.go has 509 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      /* @file @copyright defined in aergo/LICENSE.txt */
      
      package p2p
      
      import (
      Severity: Minor
      Found in p2p/peermanager.go - About 2 hrs to fix

        There are no issues that match your filters.

        Category
        Status