waku-org/go-waku

View on GitHub

Showing 400 of 400 total issues

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

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

              if options.RLNRelay.Enable {
                  spamHandler := func(message *pb.WakuMessage, topic string) error {
                      return nil
                  }
          
          
          Severity: Major
          Found in examples/chat2-reliable/exec.go and 1 other location - About 1 hr to fix
          examples/chat2/exec.go on lines 45..66

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

          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

              if options.RLNRelay.Enable {
                  spamHandler := func(message *pb.WakuMessage, topic string) error {
                      return nil
                  }
          
          
          Severity: Major
          Found in examples/chat2/exec.go and 1 other location - About 1 hr to fix
          examples/chat2-reliable/exec.go on lines 46..67

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

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

                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

                      Function getConfig has 66 lines of code (exceeds 50 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

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

                        package rest
                        
                        import (
                            "database/sql"
                            "testing"
                        Severity: Major
                        Found in cmd/waku/server/rest/utils_test.go and 1 other location - About 1 hr to fix
                        waku/v2/protocol/legacy_store/utils_test.go on lines 1..23

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

                        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

                        package legacy_store
                        
                        import (
                            "database/sql"
                            "testing"
                        Severity: Major
                        Found in waku/v2/protocol/legacy_store/utils_test.go and 1 other location - About 1 hr to fix
                        cmd/waku/server/rest/utils_test.go on lines 1..23

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

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

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

                            func (s *FilterTestSuite) TestPubSubMultiContentTopic() {
                            
                                // Create test context
                                s.ctx, s.ctxCancel = context.WithTimeout(context.Background(), 20*time.Second) // Test can't exceed 10 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 138..156

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language