waku-org/go-waku

View on GitHub

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"))
Severity: Minor
Found in waku/v2/protocol/legacy_store/waku_store_protocol_test.go - About 1 hr to fix

    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),
    Severity: Major
    Found in waku/v2/api/missing/missing_messages.go - About 1 hr to fix

      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()
      Severity: Major
      Found in waku/v2/protocol/noise/pairing.go - About 1 hr to fix

        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
        Severity: Minor
        Found in waku/v2/node/wakunode2_rln.go - About 1 hr to fix

          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 {
          Severity: Minor
          Found in waku/v2/api/publish/message_check.go - About 1 hr to fix

            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,
            Severity: Minor
            Found in examples/chat2/chat.go - About 1 hr to fix

              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),
              Severity: Minor
              Found in waku/v2/api/publish/message_sender.go - About 1 hr to fix

                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")
                Severity: Minor
                Found in examples/basic-relay/main.go - About 1 hr to fix

                  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)
                  Severity: Minor
                  Found in waku/v2/rendezvous/rendezvous_test.go - About 1 hr to fix

                    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{}
                    
                    
                    Severity: Minor
                    Found in waku/v2/protocol/lightpush/waku_lightpush.go - About 1 hr to fix

                      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
                      Severity: Minor
                      Found in waku/v2/node/wakunode2.go - About 1 hr 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

                      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
                      
                      
                      Severity: Major
                      Found in waku/v2/node/wakunode2.go - About 1 hr to fix

                        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
                            }
                        
                        
                        Severity: Minor
                        Found in waku/v2/protocol/store/pb/validation.go - About 1 hr 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

                        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)
                        Severity: Major
                        Found in waku/v2/protocol/noise/pairing.go - About 1 hr to fix

                          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 {
                          Severity: Minor
                          Found in library/config.go - About 1 hr 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

                          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()
                          Severity: Minor
                          Found in waku/v2/protocol/noise/pairing.go - About 1 hr 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

                          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)
                          Severity: Minor
                          Found in waku/v2/protocol/peer_exchange/waku_peer_exchange_test.go - About 1 hr to fix

                            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))
                            Severity: Minor
                            Found in cmd/waku/server/rest/legacy_store_test.go - About 1 hr to fix

                              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 {
                              Severity: Minor
                              Found in cmd/waku/relay.go - About 1 hr to fix

                                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)
                                
                                
                                Severity: Minor
                                Found in waku/v2/protocol/rln/rln_relay_test.go - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language