waku-org/go-waku

View on GitHub

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

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

      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)
      }
      Severity: Minor
      Found in waku/v2/peerstore/inherited.go - About 3 hrs to fix

        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
        Severity: Minor
        Found in waku/v2/node/wakunode2.go - About 3 hrs 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 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()
        Severity: Minor
        Found in waku/v2/protocol/legacy_store/waku_store_client.go - About 3 hrs 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 main has 111 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func main() {
            // Defaults
            options.LogLevel = "INFO"
            options.LogEncoding = "console"
        
        
        Severity: Major
        Found in cmd/waku/main.go - About 3 hrs to fix

          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
          Severity: Major
          Found in cmd/waku/server/rest/store.go - About 3 hrs to fix

            Function newTestCases has 107 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func newTestCases() []*testCase {
                return []*testCase{
                    {
                        description: "SameResponse",
                        servers:     mockedServers,
            Severity: Major
            Found in waku/v2/timesource/ntp_test.go - About 3 hrs to fix

              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 {
              Severity: Minor
              Found in cmd/waku/relay.go - About 3 hrs 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 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
              
              
              Severity: Major
              Found in examples/chat2-reliable/chat.go - About 3 hrs to fix

                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 {
                Severity: Major
                Found in waku/v2/node/keepalive.go - About 3 hrs to fix

                  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()
                  Severity: Major
                  Found in waku/v2/protocol/legacy_store/waku_store_client.go - About 3 hrs to fix

                    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{
                    Severity: Major
                    Found in waku/v2/protocol/subscription/subscriptions_map_test.go - About 3 hrs to fix

                      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
                      Severity: Major
                      Found in cmd/waku/server/rest/filter_test.go - About 2 hrs to fix

                        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
                            }
                        
                        
                        Severity: Major
                        Found in library/node.go - About 2 hrs to fix

                          PeerManager has 25 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                          type PeerManager struct {
                              peerConnector          *PeerConnectionStrategy
                              metadata               *metadata.WakuMetadata
                              relay                  *relay.WakuRelay
                              maxPeers               int
                          Severity: Minor
                          Found in waku/v2/peermanager/peer_manager.go - About 2 hrs to fix

                            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
                            Severity: Minor
                            Found in waku/v2/protocol/filter/client.go - About 2 hrs 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

                            File flags.go has 526 lines of code (exceeds 500 allowed). Consider refactoring.
                            Open

                            package main
                            
                            import (
                                "time"
                            
                            
                            Severity: Minor
                            Found in cmd/waku/flags.go - About 2 hrs to fix

                              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))
                              Severity: Minor
                              Found in waku/v2/peermanager/peer_manager.go - About 2 hrs 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 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
                                  }
                              Severity: Minor
                              Found in waku/v2/node/localnode.go - About 2 hrs 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

                              Severity
                              Category
                              Status
                              Source
                              Language