waku-org/go-waku

View on GitHub

Showing 300 of 401 total issues

Function FilterSubscribe has 5 return statements (exceeds 4 allowed).
Open

func FilterSubscribe(instance *WakuInstance, filterJSON string, peerID string, ms int) (string, error) {
    cf, err := toContentFilter(filterJSON)
    if err != nil {
        return "", err
    }
Severity: Major
Found in library/filter.go - About 35 mins to fix

    Method WakuFilterLightNode.unsubscribeAll has a Cognitive Complexity of 22 (exceeds 20 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 35 mins 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 encryptSymmetric has 5 return statements (exceeds 4 allowed).
    Open

    func encryptSymmetric(rawPayload []byte, key []byte) ([]byte, error) {
        if !validateDataIntegrity(key, aesKeyLength) {
            return nil, errors.New("invalid key provided for symmetric encryption, size: " + strconv.Itoa(len(key)))
        }
        block, err := aes.NewCipher(key)
    Severity: Major
    Found in waku/v2/payload/waku_payload.go - About 35 mins to fix

      Function Start has 5 return statements (exceeds 4 allowed).
      Open

      func Start(instance *WakuInstance) error {
          if err := validateInstance(instance, MustBeStopped); err != nil {
              return err
          }
      
      
      Severity: Major
      Found in library/node.go - About 35 mins to fix

        Method PushRpc.ValidateResponse has 5 return statements (exceeds 4 allowed).
        Open

        func (x *PushRpc) ValidateResponse(requestID string) error {
            if x.RequestId == REQUESTID_RATE_LIMITED {
                return nil
            }
            if x.RequestId == "" {
        Severity: Major
        Found in waku/v2/protocol/lightpush/pb/validation.go - About 35 mins to fix

          Method WakuStore.Request has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
          Open

          func (s *WakuStore) Request(ctx context.Context, criteria Criteria, opts ...RequestOption) (Result, error) {
              params := new(Parameters)
          
              optList := DefaultOptions()
              optList = append(optList, opts...)
          Severity: Minor
          Found in waku/v2/protocol/store/client.go - About 35 mins 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 handleRelayTopics has 5 return statements (exceeds 4 allowed).
          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: Major
          Found in cmd/waku/relay.go - About 35 mins to fix

            Method WakuRelay.subscribeToPubsubTopic has 5 return statements (exceeds 4 allowed).
            Open

            func (w *WakuRelay) subscribeToPubsubTopic(topic string) (*pubsubTopicSubscriptionDetails, error) {
                w.topicsMutex.Lock()
                defer w.topicsMutex.Unlock()
                w.log.Info("subscribing to underlying pubsubTopic", zap.String("pubsubTopic", topic))
            
            
            Severity: Major
            Found in waku/v2/protocol/relay/waku_relay.go - About 35 mins to fix

              Method WakuFilterLightNode.handleFilterSubscribeOptions has 5 return statements (exceeds 4 allowed).
              Open

              func (wf *WakuFilterLightNode) handleFilterSubscribeOptions(ctx context.Context, contentFilter protocol.ContentFilter, opts []FilterSubscribeOption) (*FilterSubscribeParameters, map[string][]string, error) {
                  params := new(FilterSubscribeParameters)
                  params.log = wf.log
                  params.host = wf.h
                  params.pm = wf.pm
              Severity: Major
              Found in waku/v2/protocol/filter/client.go - About 35 mins to fix

                Method LightpushService.postMessagev1 has 5 return statements (exceeds 4 allowed).
                Open

                func (serv *LightpushService) postMessagev1(w http.ResponseWriter, req *http.Request) {
                    request := &lightpushRequest{}
                    decoder := json.NewDecoder(req.Body)
                    if err := decoder.Decode(request); err != nil {
                        w.WriteHeader(http.StatusBadRequest)
                Severity: Major
                Found in cmd/waku/server/rest/lightpush_rest.go - About 35 mins to fix

                  Method WakuStore.Resume has 5 return statements (exceeds 4 allowed).
                  Open

                  func (store *WakuStore) Resume(ctx context.Context, pubsubTopic string, peerList []peer.ID) (int, error) {
                      if !store.started {
                          return 0, errors.New("can't resume: store has not started")
                      }
                  
                  
                  Severity: Major
                  Found in waku/v2/protocol/legacy_store/waku_store_protocol.go - About 35 mins to fix

                    Method WakuMetadata.Request has 5 return statements (exceeds 4 allowed).
                    Open

                    func (wakuM *WakuMetadata) Request(ctx context.Context, peerID peer.ID) (*pb.WakuMetadataResponse, error) {
                        logger := wakuM.log.With(logging.HostID("peer", peerID))
                    
                        stream, err := wakuM.h.NewStream(ctx, peerID, MetadataID_v1)
                        if err != nil {
                    Severity: Major
                    Found in waku/v2/protocol/metadata/waku_metadata.go - About 35 mins to fix

                      Function TestSubscriptionsNotify has 5 return statements (exceeds 4 allowed).
                      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 35 mins to fix

                        Function decryptSymmetric has 5 return statements (exceeds 4 allowed).
                        Open

                        func decryptSymmetric(payload []byte, key []byte) ([]byte, error) {
                            // symmetric messages are expected to contain the 12-byte nonce at the end of the payload
                            if len(payload) < aesNonceLength {
                                return nil, errors.New("missing salt or invalid payload in symmetric message")
                            }
                        Severity: Major
                        Found in waku/v2/payload/waku_payload.go - About 35 mins to fix

                          Function execute has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func execute(options Options) {
                              var err error
                              hostAddr, _ := net.ResolveTCPAddr("tcp", fmt.Sprintf("0.0.0.0:%d", options.Port))
                          
                              if options.NodeKey == nil {
                          Severity: Minor
                          Found in examples/chat2-reliable/exec.go - About 25 mins 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.discoverNodes has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func (c *Chat) discoverNodes(connectionWg *sync.WaitGroup) {
                              defer c.wg.Done()
                              defer connectionWg.Done()
                          
                              <-c.uiReady // wait until UI is ready
                          Severity: Minor
                          Found in examples/chat2/chat.go - About 25 mins 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 DB.Discover has a Cognitive Complexity of 21 (exceeds 20 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 25 mins 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 Multiaddress has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func Multiaddress(node *enode.Node) (peer.ID, []multiaddr.Multiaddr, error) {
                              pubKey := utils.EcdsaPubKeyToSecp256k1PublicKey(node.Pubkey())
                              peerID, err := peer.IDFromPublicKey(pubKey)
                              if err != nil {
                                  return "", nil, err
                          Severity: Minor
                          Found in waku/v2/protocol/enr/enr.go - About 25 mins 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 WakuPeerExchange.handleResponse has a Cognitive Complexity of 21 (exceeds 20 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 25 mins 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 DecodePayload has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func DecodePayload(message *pb.WakuMessage, keyInfo *KeyInfo) (*DecodedPayload, error) {
                              switch message.GetVersion() {
                              case uint32(0):
                                  return &DecodedPayload{Data: message.Payload}, nil
                              case uint32(1):
                          Severity: Minor
                          Found in waku/v2/payload/waku_payload.go - About 25 mins 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