File wakunode2.go
has 781 lines of code (exceeds 500 allowed). Consider refactoring. Open
package node
import (
"context"
"math/rand"
Function New
has a Cognitive Complexity of 51 (exceeds 20 allowed). Consider refactoring. Open
func New(opts ...WakuNodeOption) (*WakuNode, error) {
var err error
params := new(WakuNodeParameters)
params.libP2POpts = DefaultLibP2POptions
- 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
WakuNode
has 40 methods (exceeds 20 allowed). Consider refactoring. Open
type WakuNode struct {
host host.Host
opts *WakuNodeParameters
log *zap.Logger
timesource timesource.Timesource
Function New
has 141 lines of code (exceeds 50 allowed). Consider refactoring. Open
func New(opts ...WakuNodeOption) (*WakuNode, error) {
var err error
params := new(WakuNodeParameters)
params.libP2POpts = DefaultLibP2POptions
Method WakuNode.Start
has 127 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (w *WakuNode) Start(ctx context.Context) error {
connGater := peermanager.NewConnectionGater(w.opts.maxConnectionsPerIP, w.log)
ctx, cancel := context.WithCancel(ctx)
w.cancel = cancel
Method WakuNode.Start
has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring. Open
func (w *WakuNode) Start(ctx context.Context) error {
connGater := peermanager.NewConnectionGater(w.opts.maxConnectionsPerIP, w.log)
ctx, cancel := context.WithCancel(ctx)
w.cancel = cancel
- 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 WakuNode.Start
has 18 return statements (exceeds 4 allowed). Open
func (w *WakuNode) Start(ctx context.Context) error {
connGater := peermanager.NewConnectionGater(w.opts.maxConnectionsPerIP, w.log)
ctx, cancel := context.WithCancel(ctx)
w.cancel = cancel
Method WakuNode.findRelayNodes
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func (w *WakuNode) findRelayNodes(ctx context.Context) {
defer utils.LogOnPanic()
defer w.wg.Done()
// Feed peers more often right after the bootstrap, then backoff
- 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
Function New
has 13 return statements (exceeds 4 allowed). Open
func New(opts ...WakuNodeOption) (*WakuNode, error) {
var err error
params := new(WakuNodeParameters)
params.libP2POpts = DefaultLibP2POptions
Method WakuNode.findRelayNodes
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (w *WakuNode) findRelayNodes(ctx context.Context) {
defer utils.LogOnPanic()
defer w.wg.Done()
// Feed peers more often right after the bootstrap, then backoff
Avoid deeply nested control flow statements. Open
if prevNodeVal == "" {
w.log.Info("local node enr record", logging.ENode("enr", w.localNode.Node()))
} else {
w.log.Info("local node new enr record", logging.ENode("enr", w.localNode.Node()))
}
Method WakuNode.AddDiscoveredPeer
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func (w *WakuNode) AddDiscoveredPeer(ID peer.ID, addrs []ma.Multiaddr, origin wps.Origin, pubsubTopics []string, enr *enode.Node, connectNow bool) {