waku-org/go-waku

View on GitHub

Showing 400 of 400 total issues

Function execute has 7 return statements (exceeds 4 allowed).
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: Major
Found in examples/chat2/exec.go - About 45 mins to fix

    Method StaticShardingPubsubTopic.Parse has 7 return statements (exceeds 4 allowed).
    Open

    func (s *StaticShardingPubsubTopic) Parse(topic string) error {
        if !strings.HasPrefix(topic, StaticShardingPubsubTopicPrefix) {
            return ErrInvalidShardedTopicPrefix
        }
    
    
    Severity: Major
    Found in waku/v2/protocol/pubsub_topic.go - About 45 mins to fix

      Method WakuStore.queryFrom has 7 return statements (exceeds 4 allowed).
      Open

      func (s *WakuStore) queryFrom(ctx context.Context, storeRequest *pb.StoreQueryRequest, params *Parameters) (*pb.StoreQueryResponse, error) {
          logger := s.log.With(logging.HostID("peer", params.selectedPeer), zap.String("requestId", storeRequest.RequestId))
      
          logger.Debug("sending store request")
      
      
      Severity: Major
      Found in waku/v2/protocol/store/client.go - About 45 mins to fix

        Function waku_content_topic has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        func waku_content_topic(applicationName *C.char, applicationVersion *C.char, contentTopicName *C.char, encoding *C.char, cb C.WakuCallBack, userData unsafe.Pointer) C.int {
        Severity: Minor
        Found in library/c/api.go - About 45 mins to fix

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

          func (wakuPX *WakuPeerExchange) Request(ctx context.Context, numPeers int, opts ...RequestOption) error {
              params := new(PeerExchangeRequestParameters)
              params.host = wakuPX.h
              params.log = wakuPX.log
              params.pm = wakuPX.pm
          Severity: Minor
          Found in waku/v2/protocol/peer_exchange/client.go - About 45 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 waku_filter_subscribe has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          func waku_filter_subscribe(ctx unsafe.Pointer, filterJSON *C.char, peerID *C.char, ms C.int, cb C.WakuCallBack, userData unsafe.Pointer) C.int {
          Severity: Minor
          Found in library/c/api_filter.go - About 45 mins to fix

            Function waku_dns_discovery has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            func waku_dns_discovery(ctx unsafe.Pointer, url *C.char, nameserver *C.char, ms C.int, cb C.WakuCallBack, userData unsafe.Pointer) C.int {
            Severity: Minor
            Found in library/c/api_discovery.go - About 45 mins to fix

              Method WakuFilterLightNode.Unsubscribe has 7 return statements (exceeds 4 allowed).
              Open

              func (wf *WakuFilterLightNode) Unsubscribe(ctx context.Context, contentFilter protocol.ContentFilter, opts ...FilterSubscribeOption) (*WakuFilterPushResult, error) {
                  wf.RLock()
                  defer wf.RUnlock()
                  if err := wf.ErrOnNotRunning(); err != nil {
                      return nil, err
              Severity: Major
              Found in waku/v2/protocol/filter/client.go - About 45 mins to fix

                Method Payload.Encode has 7 return statements (exceeds 4 allowed).
                Open

                func (payload Payload) Encode(version uint32) ([]byte, error) {
                    switch version {
                    case 0:
                        return payload.Data, nil
                    case 1:
                Severity: Major
                Found in waku/v2/payload/waku_payload.go - About 45 mins to fix

                  Function NewWakuRelay has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  func NewWakuRelay(bcaster Broadcaster, minPeersToPublish int, timesource timesource.Timesource,
                      reg prometheus.Registerer, log *zap.Logger, opts ...RelayOption) *WakuRelay {
                  Severity: Minor
                  Found in waku/v2/protocol/relay/waku_relay.go - About 45 mins to fix

                    Method WakuPeerExchange.onRequest has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (wakuPX *WakuPeerExchange) onRequest() func(network.Stream) {
                        return func(stream network.Stream) {
                            logger := wakuPX.log.With(logging.HostID("peer", stream.Conn().RemotePeer()))
                    
                            if wakuPX.limiter != nil && !wakuPX.limiter.Allow() {
                    Severity: Minor
                    Found in waku/v2/protocol/peer_exchange/protocol.go - About 45 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 DecodeAsymmetric has 7 return statements (exceeds 4 allowed).
                    Open

                    func DecodeAsymmetric(messageJSON string, privateKey string) (string, error) {
                        var msg pb.WakuMessage
                        err := json.Unmarshal([]byte(messageJSON), &msg)
                        if err != nil {
                            return "", err
                    Severity: Major
                    Found in library/encoding.go - About 45 mins to fix

                      Function StringToQR has 7 return statements (exceeds 4 allowed).
                      Open

                      func StringToQR(qrString string) (QR, error) {
                          values := strings.Split(qrString, ":")
                          if len(values) != 5 {
                              return QR{}, errors.New("invalid qr string")
                          }
                      Severity: Major
                      Found in waku/v2/protocol/noise/qr.go - About 45 mins to fix

                        Function waku_store_query has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        func waku_store_query(ctx unsafe.Pointer, queryJSON *C.char, peerID *C.char, ms C.int, cb C.WakuCallBack, userData unsafe.Pointer) C.int {
                        Severity: Minor
                        Found in library/c/api_store.go - About 45 mins to fix

                          Function waku_filter_unsubscribe has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          func waku_filter_unsubscribe(ctx unsafe.Pointer, filterJSON *C.char, peerID *C.char, ms C.int, cb C.WakuCallBack, userData unsafe.Pointer) C.int {
                          Severity: Minor
                          Found in library/c/api_filter.go - About 45 mins to fix

                            Function NewWakuFilterLightNode has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                broadcaster relay.Broadcaster,
                                pm *peermanager.PeerManager,
                                timesource timesource.Timesource,
                                onlineChecker onlinechecker.OnlineChecker,
                                reg prometheus.Registerer,
                            Severity: Minor
                            Found in waku/v2/protocol/filter/client.go - About 45 mins to fix

                              Method WakuFilterLightNode.Subscribe has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                              Open

                              func (wf *WakuFilterLightNode) Subscribe(ctx context.Context, contentFilter protocol.ContentFilter, opts ...FilterSubscribeOption) ([]*subscription.SubscriptionDetails, error) {
                                  wf.RLock()
                                  defer wf.RUnlock()
                                  if err := wf.ErrOnNotRunning(); err != nil {
                                      return nil, err
                              Severity: Minor
                              Found in waku/v2/protocol/filter/client.go - About 45 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 waku_relay_publish has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              func waku_relay_publish(ctx unsafe.Pointer, messageJSON *C.char, topic *C.char, ms C.int, cb C.WakuCallBack, userData unsafe.Pointer) C.int {
                              Severity: Minor
                              Found in library/c/api_relay.go - About 45 mins to fix

                                Function validateInstance has 7 return statements (exceeds 4 allowed).
                                Open

                                func validateInstance(instance *WakuInstance, validationType ValidationType) error {
                                    if instance == nil {
                                        return errWakuNodeNotReady
                                    }
                                
                                
                                Severity: Major
                                Found in library/node.go - About 45 mins to fix

                                  Function EncodeSymmetric has 7 return statements (exceeds 4 allowed).
                                  Open

                                  func EncodeSymmetric(messageJSON string, symmetricKey string, optionalSigningKey string) (string, error) {
                                      msg, err := wakuMessage(messageJSON)
                                      if err != nil {
                                          return "", err
                                      }
                                  Severity: Major
                                  Found in library/encoding.go - About 45 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language