waku-org/go-waku

View on GitHub

Showing 400 of 400 total issues

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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        func TestRecordErrorIteratorFailure(t *testing.T) {
        
            m := newMetrics(prometheus.DefaultRegisterer)
        
            // Increment error counter for rateLimitFailure 7 times
        Severity: Major
        Found in waku/v2/discv5/discover_test.go and 1 other location - About 1 hr to fix
        waku/v2/protocol/peer_exchange/waku_peer_exchange_test.go on lines 418..438

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 151.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        func TestRecordError(t *testing.T) {
        
            m := newMetrics(prometheus.DefaultRegisterer)
        
            // Increment error counter for rateLimitFailure 7 times
        Severity: Major
        Found in waku/v2/protocol/peer_exchange/waku_peer_exchange_test.go and 1 other location - About 1 hr to fix
        waku/v2/discv5/discover_test.go on lines 339..359

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 151.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

            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 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

                  Identical blocks of code found in 2 locations. Consider refactoring.
                  Open

                      for _, n := range c.options.StaticNodes {
                          go func(addr multiaddr.Multiaddr) {
                              defer wg.Done()
                              ctx, cancel := context.WithTimeout(c.ctx, time.Duration(10)*time.Second)
                              defer cancel()
                  Severity: Major
                  Found in examples/chat2-reliable/chat.go and 1 other location - About 1 hr to fix
                  examples/chat2/chat.go on lines 425..438

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 149.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Identical blocks of code found in 2 locations. Consider refactoring.
                  Open

                      for _, n := range options.StaticNodes {
                          go func(addr multiaddr.Multiaddr) {
                              defer wg.Done()
                              ctx, cancel := context.WithTimeout(c.ctx, time.Duration(10)*time.Second)
                              defer cancel()
                  Severity: Major
                  Found in examples/chat2/chat.go and 1 other location - About 1 hr to fix
                  examples/chat2-reliable/chat.go on lines 439..452

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 149.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  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

                    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

                      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

                          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

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