waku-org/go-waku

View on GitHub

Showing 400 of 400 total issues

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

func (s *FilterTestSuite) TestPubSubMultiOverlapContentTopic() {

    // Create test context
    s.ctx, s.ctxCancel = context.WithTimeout(context.Background(), 20*time.Second) // Test can't exceed 20 seconds

Severity: Major
Found in waku/v2/protocol/filter/filter_subscribe_test.go and 1 other location - About 1 hr to fix
waku/v2/protocol/filter/filter_subscribe_test.go on lines 80..98

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

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

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

              for _, ct := range []string{contentTopics1, contentTopics2} {
                  requestID := hex.EncodeToString(protocol.GenerateRequestID())
                  rr := httptest.NewRecorder()
                  reqReader := strings.NewReader(toString(t, filterSubscriptionRequest{
                      RequestID:      requestID,
          Severity: Major
          Found in cmd/waku/server/rest/filter_test.go and 1 other location - About 1 hr to fix
          cmd/waku/server/rest/filter_test.go on lines 279..294

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

          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

                  for _, pubsubTopic := range []string{"", pubsubTopic} {
                      requestID := hex.EncodeToString(protocol.GenerateRequestID())
                      rr := httptest.NewRecorder()
                      reqReader := strings.NewReader(toString(t, filterSubscriptionRequest{
                          RequestID:      requestID,
          Severity: Major
          Found in cmd/waku/server/rest/filter_test.go and 1 other location - About 1 hr to fix
          cmd/waku/server/rest/filter_test.go on lines 195..210

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

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

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

                  if ascendingStr != "" || pageSizeStr != "" {
                      ascending := true
                      pageSize := uint64(legacy_store.DefaultPageSize)
                      if ascendingStr != "" {
                          ascending, err = strconv.ParseBool(ascendingStr)
              Severity: Major
              Found in cmd/waku/server/rest/legacy_store.go and 1 other location - About 1 hr to fix
              cmd/waku/server/rest/store.go on lines 129..150

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

              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

                  if ascendingStr != "" || pageSizeStr != "" {
                      ascending := true
                      pageSize := uint64(legacy_store.DefaultPageSize)
                      if ascendingStr != "" {
                          ascending, err = strconv.ParseBool(ascendingStr)
              Severity: Major
              Found in cmd/waku/server/rest/store.go and 1 other location - About 1 hr to fix
              cmd/waku/server/rest/legacy_store.go on lines 139..160

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

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

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

                      /**
                       * Decode a waku message using a symmetric key
                       * @param msg Message to decode
                       * @param privateKey Symmetric key used to decode the message
                       * @return DecodedPayload containing the decrypted message, padding, public key and signature (if available)
                      examples/android-kotlin/app/src/main/java/com/example/waku/messages/Message.kt on lines 18..28

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

                      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

                      /**
                       * Decode a waku message using an asymmetric key
                       * @param msg Message to decode
                       * @param privateKey Secp256k1 private key used to decode the message
                       * @return DecodedPayload containing the decrypted message, padding, public key and signature (if available)
                      examples/android-kotlin/app/src/main/java/com/example/waku/messages/Message.kt on lines 30..40

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

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