waku-org/go-waku

View on GitHub

Showing 299 of 400 total issues

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

          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

                    Method StoreQueryRequest.Validate has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (x *StoreQueryRequest) Validate() error {
                        if x.RequestId == "" {
                            return errMissingRequestID
                        }
                    
                    
                    Severity: Minor
                    Found in waku/v2/protocol/store/pb/validation.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 TestRetrieveProvidePeerExchangePeers has 56 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func TestRetrieveProvidePeerExchangePeers(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

                      Function TestGetMessages has 56 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func TestGetMessages(t *testing.T) {
                      
                          db := MemoryDB(t)
                      
                          node1, err := node.New(node.WithWakuStore(), node.WithMessageProvider(db))
                      Severity: Minor
                      Found in cmd/waku/server/rest/legacy_store_test.go - About 1 hr to fix

                        Function handleRelayTopics has 56 lines of code (exceeds 50 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 1 hr to fix

                          Method WakuRLNRelaySuite.TestUpdateLogAndHasDuplicate has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (s *WakuRLNRelaySuite) TestUpdateLogAndHasDuplicate() {
                          
                              rlnInstance, err := r.NewRLN()
                              s.Require().NoError(err)
                          
                          
                          Severity: Minor
                          Found in waku/v2/protocol/rln/rln_relay_test.go - About 1 hr to fix

                            Function TestDiscV5WithCapabilitiesFilter has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func TestDiscV5WithCapabilitiesFilter(t *testing.T) {
                            
                                // H1
                                host1, _, prvKey1 := tests.CreateHost(t)
                                udpPort1, err := tests.FindFreeUDPPort(t, "127.0.0.1", 3)
                            Severity: Minor
                            Found in waku/v2/discv5/discover_test.go - About 1 hr to fix

                              Function TestWakuStoreWithStaticSharding has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func TestWakuStoreWithStaticSharding(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 12 return statements (exceeds 4 allowed).
                                Open

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