waku-org/go-waku

View on GitHub

Showing 299 of 400 total issues

Function TestBackwardPagination has 65 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func TestBackwardPagination(t *testing.T) {
    msgList := createSampleList(10)
    db := MemoryDB(t)
    for _, m := range msgList {
        err := db.Put(m)
Severity: Minor
Found in waku/v2/protocol/legacy_store/waku_store_pagination_test.go - About 1 hr to fix

    Function TestQueryOptions has 65 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func TestQueryOptions(t *testing.T) {
        ctx, cancel := context.WithCancel(context.Background())
        defer cancel()
    
        pubSubTopic := "/waku/2/go/store/test"
    Severity: Minor
    Found in waku/v2/protocol/legacy_store/waku_store_client_test.go - About 1 hr to fix

      Function getGossipSubParams has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
      Open

      func getGossipSubParams(cfg *GossipSubParams) pubsub.GossipSubParams {
          params := pubsub.DefaultGossipSubParams()
      
          if cfg.D != nil {
              params.D = *cfg.D
      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

      Function TestWakuLightPush has 64 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func TestWakuLightPush(t *testing.T) {
          testTopic := "/waku/2/go/lightpush/test"
          node1, sub1, host1 := makeWakuRelay(t, testTopic)
          defer node1.Stop()
          defer sub1.Unsubscribe()
      Severity: Minor
      Found in waku/v2/protocol/lightpush/waku_lightpush_test.go - About 1 hr to fix

        Method mockStore.Populate has 63 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (t *mockStore) Populate(topics []string, responses int, includeRandomError bool) error {
            if responses <= 0 || len(topics) == 0 {
                return errors.New("invalid input parameters")
            }
        
        
        Severity: Minor
        Found in waku/v2/api/history/history_test.go - About 1 hr to fix

          Method WakuFilterLightNode.unsubscribeAll has 63 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (wf *WakuFilterLightNode) unsubscribeAll(ctx context.Context, opts ...FilterSubscribeOption) (*WakuFilterPushResult, error) {
              params, err := wf.getUnsubscribeParameters(opts...)
              if err != nil {
                  return nil, err
              }
          Severity: Minor
          Found in waku/v2/protocol/filter/client.go - About 1 hr to fix

            Function TestRetrieveFilteredPeerExchangePeers has 63 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func TestRetrieveFilteredPeerExchangePeers(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 TestDiscV5 has 62 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func TestDiscV5(t *testing.T) {
                  // Host1 <-> Host2 <-> Host3
                  // Host4(No waku capabilities) <-> Host2
              
                  // H1
              Severity: Minor
              Found in waku/v2/discv5/discover_test.go - About 1 hr to fix

                Function TestForwardPagination has 62 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func TestForwardPagination(t *testing.T) {
                    msgList := createSampleList(10)
                    db := MemoryDB(t)
                    for _, m := range msgList {
                        err := db.Put(m)
                Severity: Minor
                Found in waku/v2/protocol/legacy_store/waku_store_pagination_test.go - About 1 hr to fix

                  Function TestHandler has 61 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func TestHandler(t *testing.T) {
                      // Create a RLN instance
                      rlnInstance, err := rln.NewRLN()
                      require.NoError(t, err)
                  
                  
                  Severity: Minor
                  Found in waku/v2/protocol/rln/group_manager/dynamic/handler_test.go - About 1 hr to fix

                    Function TestStaticShardingMultipleTopics has 61 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func TestStaticShardingMultipleTopics(t *testing.T) {
                        ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
                        defer cancel()
                    
                        testClusterID := uint16(20)
                    Severity: Minor
                    Found in waku/v2/node/wakunode2_test.go - About 1 hr to fix

                      Method FastestPeerSelector.FastestPeer has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (r *FastestPeerSelector) FastestPeer(ctx context.Context, peers peer.IDSlice) (peer.ID, error) {
                          var peerRTT []pingResult
                          var peerRTTMutex sync.Mutex
                      
                          wg := sync.WaitGroup{}
                      Severity: Minor
                      Found in waku/v2/peermanager/fastest_peer_selector.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 testQuery has 60 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func testQuery(t *testing.T, db *sql.DB, migrationFn func(*sql.DB, *zap.Logger) error) {
                          store, err := persistence.NewDBStore(prometheus.DefaultRegisterer, utils.Logger(), persistence.WithDB(db), persistence.WithMigrations(migrationFn), persistence.WithRetentionPolicy(5, 20*time.Second))
                          require.NoError(t, err)
                      
                          insertTime := time.Now()
                      Severity: Minor
                      Found in waku/persistence/utils/store_test.go - About 1 hr to fix

                        Method WakuPeerExchange.handleResponse has 60 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (wakuPX *WakuPeerExchange) handleResponse(ctx context.Context, response *pb.PeerExchangeResponse, params *PeerExchangeRequestParameters) error {
                            var discoveredPeers []struct {
                                addrInfo peer.AddrInfo
                                enr      *enode.Node
                            }
                        Severity: Minor
                        Found in waku/v2/protocol/peer_exchange/client.go - About 1 hr to fix

                          Method FilterApiTestSuite.TestFilterManager has 59 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (s *FilterApiTestSuite) TestFilterManager() {
                              ctx, cancel := context.WithCancel(context.Background())
                          
                              testPubsubTopic := s.TestTopic
                              contentTopicBytes := make([]byte, 4)
                          Severity: Minor
                          Found in waku/v2/api/filter/filter_test.go - About 1 hr to fix

                            Function TestNetworkPartition has 59 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func TestNetworkPartition(t *testing.T) {
                                ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
                                defer cancel()
                            
                                t.Log("Starting TestMessageRecovery")
                            Severity: Minor
                            Found in examples/chat2-reliable/chat_reliability_test.go - About 1 hr to fix

                              Method WakuFilterLightNode.request has 59 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func (wf *WakuFilterLightNode) request(ctx context.Context, requestID []byte,
                                  reqType pb.FilterSubscribeRequest_FilterSubscribeType, contentFilter protocol.ContentFilter, peerID peer.ID) error {
                                  request := &pb.FilterSubscribeRequest{
                                      RequestId:           hex.EncodeToString(requestID),
                                      FilterSubscribeType: reqType,
                              Severity: Minor
                              Found in waku/v2/protocol/filter/client.go - About 1 hr to fix

                                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

                                  Function TestWakuStoreProtocolFind has 59 lines of code (exceeds 50 allowed). Consider refactoring.
                                  Open

                                  func TestWakuStoreProtocolFind(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
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language