Showing 300 of 401 total issues
Function TestWakuStoreProtocolNext
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestWakuStoreProtocolNext(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
host1, err := libp2p.New(libp2p.DefaultTransports, libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))
Method MissingMessageVerifier.fetchMessagesBatch
has 14 return statements (exceeds 4 allowed). 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),
Method Pairing.initiatorHandshake
has 14 return statements (exceeds 4 allowed). Open
func (p *Pairing) initiatorHandshake(ctx context.Context, msgCh <-chan *pb.WakuMessage) (doneCh chan error) {
doneCh = make(chan error, 1)
go func() {
defer utils.LogOnPanic()
Method WakuNode.setupRLNRelay
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (w *WakuNode) setupRLNRelay() error {
var err error
if !w.opts.enableRLN {
return nil
Method MessageSentCheck.Start
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *MessageSentCheck) Start() {
defer utils.LogOnPanic()
ticker := time.NewTicker(m.hashQueryInterval)
defer ticker.Stop()
for {
Function NewChat
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
func NewChat(ctx context.Context, node *node.WakuNode, connNotifier <-chan node.PeerConnection, options Options) *Chat {
chat := &Chat{
ctx: ctx,
node: node,
options: options,
Method MessageSender.Send
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (ms *MessageSender) Send(req *Request) error {
logger := ms.logger.With(
zap.Stringer("envelopeHash", req.envelope.Hash()),
zap.String("pubsubTopic", req.envelope.PubsubTopic()),
zap.String("contentTopic", req.envelope.Message().ContentTopic),
Function Execute
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func Execute() error {
var cTopic, err = protocol.NewContentTopic("basic-relay", "1", "test", "proto")
if err != nil {
fmt.Println("Invalid contentTopic")
Function TestRendezvous
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestRendezvous(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
port1, err := tests.FindFreePort(t, "", 5)
Method WakuLightPush.onRequest
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (wakuLP *WakuLightPush) onRequest(ctx context.Context) func(network.Stream) {
return func(stream network.Stream) {
logger := wakuLP.log.With(logging.HostID("peer", stream.Conn().RemotePeer()))
requestPushRPC := &pb.PushRpc{}
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 StoreQueryRequest.Validate
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func (x *StoreQueryRequest) Validate() error {
if x.RequestId == "" {
return errMissingRequestID
}
- 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 Pairing.responderHandshake
has 13 return statements (exceeds 4 allowed). Open
func (p *Pairing) responderHandshake(ctx context.Context, msgCh <-chan *pb.WakuMessage) (doneCh chan error) {
doneCh = make(chan error, 1)
func() {
defer close(doneCh)
Function getConfig
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func getConfig(configJSON string) (WakuConfig, error) {
var config WakuConfig
if configJSON != "" {
err := json.Unmarshal([]byte(configJSON), &config)
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 Pairing.initiatorHandshake
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func (p *Pairing) initiatorHandshake(ctx context.Context, msgCh <-chan *pb.WakuMessage) (doneCh chan error) {
doneCh = make(chan error, 1)
go func() {
defer utils.LogOnPanic()
- 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 TestRetrieveProvidePeerExchangePeers
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestRetrieveProvidePeerExchangePeers(t *testing.T) {
// H1
host1, _, prvKey1 := tests.CreateHost(t)
udpPort1, err := tests.FindFreePort(t, "127.0.0.1", 3)
require.NoError(t, err)
Function TestGetMessages
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestGetMessages(t *testing.T) {
db := MemoryDB(t)
node1, err := node.New(node.WithWakuStore(), node.WithMessageProvider(db))
Function handleRelayTopics
has 56 lines of code (exceeds 50 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 {
Method WakuRLNRelaySuite.TestUpdateLogAndHasDuplicate
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *WakuRLNRelaySuite) TestUpdateLogAndHasDuplicate() {
rlnInstance, err := r.NewRLN()
s.Require().NoError(err)