Showing 300 of 401 total issues
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 MissingMessageVerifier.fetchMessagesBatch
has 119 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *MissingMessageVerifier) fetchMessagesBatch(c chan<- *protocol.Envelope, interest criteriaInterest, batchFrom int, batchTo int, now time.Time) error {
contentTopics := interest.contentFilter.ContentTopics.ToList()
logger := m.logger.With(
zap.Stringer("peerID", interest.peerID),
WakuPeerstoreImpl
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
func (ps *WakuPeerstoreImpl) AddAddr(p peer.ID, addr ma.Multiaddr, ttl time.Duration) {
ps.peerStore.AddAddr(p, addr, ttl)
}
Method WakuNode.Start
has a Cognitive Complexity of 40 (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 WakuStore.Query
has a Cognitive Complexity of 40 (exceeds 20 allowed). Consider refactoring. Open
func (store *WakuStore) Query(ctx context.Context, query Query, opts ...HistoryRequestOption) (*Result, error) {
params := new(HistoryRequestParameters)
params.s = store
optList := DefaultOptions()
- 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 main
has 111 lines of code (exceeds 50 allowed). Consider refactoring. Open
func main() {
// Defaults
options.LogLevel = "INFO"
options.LogEncoding = "console"
Function getStoreParams
has 111 lines of code (exceeds 50 allowed). Consider refactoring. Open
func getStoreParams(r *http.Request) (store.Criteria, []store.RequestOption, error) {
var options []store.RequestOption
var err error
peerAddrStr := r.URL.Query().Get("peerAddr")
var m multiaddr.Multiaddr
Function newTestCases
has 107 lines of code (exceeds 50 allowed). Consider refactoring. Open
func newTestCases() []*testCase {
return []*testCase{
{
description: "SameResponse",
servers: mockedServers,
Function handleRelayTopics
has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring. Open
func handleRelayTopics(ctx context.Context, wg *sync.WaitGroup, wakuNode *node.WakuNode, pubSubTopicMap map[string][]string) error {
for nodeTopic, cTopics := range pubSubTopicMap {
nodeTopic := nodeTopic
_, err := wakuNode.Relay().Subscribe(ctx, wprotocol.NewContentFilter(nodeTopic, cTopics...), relay.WithoutConsumer())
if err != nil {
- 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 Chat.parseInput
has 106 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (c *Chat) parseInput() {
defer c.wg.Done()
var disconnectedPeers []peer.ID
Method WakuNode.startKeepAlive
has 105 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (w *WakuNode) startKeepAlive(ctx context.Context, randomPeersPingDuration time.Duration, allPeersPingDuration time.Duration) {
defer utils.LogOnPanic()
defer w.wg.Done()
if !w.opts.enableRelay {
Method WakuStore.Query
has 105 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (store *WakuStore) Query(ctx context.Context, query Query, opts ...HistoryRequestOption) (*Result, error) {
params := new(HistoryRequestParameters)
params.s = store
optList := DefaultOptions()
Function TestSubscriptionsNotify
has 101 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestSubscriptionsNotify(t *testing.T) {
fmap := NewSubscriptionMap(utils.Logger())
p1 := createPeerID(t)
p2 := createPeerID(t)
var subscriptions = []*SubscriptionDetails{
Function TestFilterGetMessages
has 97 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestFilterGetMessages(t *testing.T) {
pubsubTopic := "/waku/2/test/proto"
contentTopic := "/waku/2/app/1"
// get nodes add connect them
Function NewNode
has 96 lines of code (exceeds 50 allowed). Consider refactoring. Open
func NewNode(instance *WakuInstance, configJSON string) error {
if err := validateInstance(instance, NotConfigured); err != nil {
return err
}
PeerManager
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
type PeerManager struct {
peerConnector *PeerConnectionStrategy
metadata *metadata.WakuMetadata
relay *relay.WakuRelay
maxPeers int
Method WakuFilterLightNode.Unsubscribe
has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring. Open
func (wf *WakuFilterLightNode) Unsubscribe(ctx context.Context, contentFilter protocol.ContentFilter, opts ...FilterSubscribeOption) (*WakuFilterPushResult, error) {
wf.RLock()
defer wf.RUnlock()
if err := wf.ErrOnNotRunning(); err != nil {
return nil, err
- 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
File flags.go
has 526 lines of code (exceeds 500 allowed). Consider refactoring. Open
package main
import (
"time"
Method PeerManager.prunePeerStore
has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring. Open
func (pm *PeerManager) prunePeerStore() {
peers := pm.host.Peerstore().Peers()
numPeers := len(peers)
if numPeers < pm.maxPeers {
pm.logger.Debug("peerstore size within capacity, not pruning", zap.Int("capacity", pm.maxPeers), zap.Int("numPeers", numPeers))
- 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.watchTopicShards
has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring. Open
func (w *WakuNode) watchTopicShards(ctx context.Context) error {
evtRelaySubscribed, err := w.Relay().Events().Subscribe(new(relay.EvtRelaySubscribed))
if err != nil {
return err
}
- 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"