waku-org/go-waku

View on GitHub

Showing 300 of 401 total issues

Method WakuStore.Request has 77 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (s *WakuStore) Request(ctx context.Context, criteria Criteria, opts ...RequestOption) (Result, error) {
    params := new(Parameters)

    optList := DefaultOptions()
    optList = append(optList, opts...)
Severity: Major
Found in waku/v2/protocol/store/client.go - About 2 hrs to fix

    Function TestDecoupledStoreFromRelay has 75 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func TestDecoupledStoreFromRelay(t *testing.T) {
        ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
        defer cancel()
    
        // NODE1: Relay Node + Filter Server
    Severity: Minor
    Found in waku/v2/node/wakunode2_test.go - About 2 hrs to fix

      Function TestStaticShardingLimits has 75 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func TestStaticShardingLimits(t *testing.T) {
      
          log := utils.Logger()
      
          if os.Getenv("RUN_FLAKY_TESTS") != "true" {
      Severity: Minor
      Found in waku/v2/node/wakunode2_test.go - About 2 hrs to fix

        Method WakuFilterLightNode.IncorrectSubscribe has 75 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (wf *WakuFilterLightNode) IncorrectSubscribe(ctx context.Context, contentFilter protocol.ContentFilter, opts ...FilterSubscribeOption) ([]*subscription.SubscriptionDetails, error) {
            wf.RLock()
            defer wf.RUnlock()
            if err := wf.ErrOnNotRunning(); err != nil {
                return nil, err
        Severity: Minor
        Found in waku/v2/protocol/filter/filter_proto_ident_test.go - About 2 hrs to fix

          Method WakuPeerExchange.Request has 75 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (wakuPX *WakuPeerExchange) Request(ctx context.Context, numPeers int, opts ...RequestOption) error {
              params := new(PeerExchangeRequestParameters)
              params.host = wakuPX.h
              params.log = wakuPX.log
              params.pm = wakuPX.pm
          Severity: Minor
          Found in waku/v2/protocol/peer_exchange/client.go - About 2 hrs to fix

            Method PeerManager.prunePeerStore has 74 lines of code (exceeds 50 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))
            Severity: Minor
            Found in waku/v2/peermanager/peer_manager.go - About 1 hr to fix

              Method Pairing.responderHandshake has 74 lines of code (exceeds 50 allowed). Consider refactoring.
              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: Minor
              Found in waku/v2/protocol/noise/pairing.go - About 1 hr to fix

                Function TestWakuRelayAutoShard has 73 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func TestWakuRelayAutoShard(t *testing.T) {
                    testcTopic := "/toychat/2/huilong/proto"
                    testcTopic1 := "/toychat/1/huilong/proto"
                
                    port, err := tests.FindFreePort(t, "", 5)
                Severity: Minor
                Found in waku/v2/protocol/relay/waku_relay_test.go - About 1 hr to fix

                  Function main has 72 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func main() {
                      // Removing noisy logs
                      lvl, err := logging.LevelFromString("error")
                      if err != nil {
                          panic(err)
                  Severity: Minor
                  Found in examples/noise/main.go - About 1 hr to fix

                    Function TestWakuRLNOptions has 72 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func TestWakuRLNOptions(t *testing.T) {
                        topicHealthStatusChan := make(chan peermanager.TopicHealthStatus, 100)
                    
                        key, err := tests.RandomHex(32)
                        require.NoError(t, err)
                    Severity: Minor
                    Found in waku/v2/node/wakuoptions_test.go - About 1 hr to fix

                      Function TestWakuStoreResult has 71 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func TestWakuStoreResult(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 WakuRLNRelay.ValidateMessage has 70 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (rlnRelay *WakuRLNRelay) ValidateMessage(msg *pb.WakuMessage, optionalTime *time.Time) (messageValidationResult, error) {
                            if msg == nil {
                                return validationError, errors.New("nil message")
                            }
                        
                        
                        Severity: Minor
                        Found in waku/v2/protocol/rln/waku_rln_relay.go - About 1 hr to fix

                          Method PeerManager.selectServicePeer has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func (pm *PeerManager) selectServicePeer(criteria PeerSelectionCriteria) (PeerSet, error) {
                              peers := make(PeerSet)
                              var err error
                              for retryCnt := 0; retryCnt < 1; retryCnt++ {
                                  //Try to fetch from serviceSlot
                          Severity: Minor
                          Found in waku/v2/peermanager/peer_selection.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 WakuFilterLightNode.onRequest has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func (wf *WakuFilterLightNode) onRequest(ctx context.Context) func(network.Stream) {
                              return func(stream network.Stream) {
                                  peerID := stream.Conn().RemotePeer()
                          
                                  logger := wf.log.With(logging.HostID("peerID", peerID))
                          Severity: Minor
                          Found in waku/v2/protocol/filter/client.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 DB.Discover has 67 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (db *DB) Discover(ns string, cookie []byte, limit int) ([]dbi.RegistrationRecord, []byte, error) {
                              now := time.Now().Unix()
                          
                              var (
                                  counter int64
                          Severity: Minor
                          Found in waku/v2/rendezvous/db.go - About 1 hr to fix

                            Method WakuRLNRelaySuite.TestValidateMessage has 67 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (s *WakuRLNRelaySuite) TestValidateMessage() {
                                groupKeyPairs, _, err := r.CreateMembershipList(100)
                                s.Require().NoError(err)
                            
                                ctx, cancel := context.WithCancel(context.Background())
                            Severity: Minor
                            Found in waku/v2/protocol/rln/rln_relay_test.go - About 1 hr to fix

                              Function TestDiscV5WithShardFilter has 67 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func TestDiscV5WithShardFilter(t *testing.T) {
                              
                                  // Following topic syntax for shard /waku/2/rs/<cluster_id>/<shard_number>
                                  pubSubTopic := "/waku/2/rs/10/1"
                              
                              
                              Severity: Minor
                              Found in waku/v2/discv5/discover_test.go - About 1 hr to fix

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

                                  Method FastestPeerSelector.FastestPeer has 66 lines of code (exceeds 50 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

                                    Function NewChat has 66 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-reliable/chat.go - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language