waku-org/go-waku

View on GitHub

Showing 299 of 400 total issues

Function getLegacyStoreParams has 9 return statements (exceeds 4 allowed).
Open

func getLegacyStoreParams(r *http.Request) (*legacy_store.Query, []legacy_store.HistoryRequestOption, error) {
    query := &legacy_store.Query{}
    var options []legacy_store.HistoryRequestOption
    var err error
    peerAddrStr := r.URL.Query().Get("peerAddr")
Severity: Major
Found in cmd/waku/server/rest/legacy_store.go - About 55 mins to fix

    Method WakuStore.Query has 9 return statements (exceeds 4 allowed).
    Open

    func (store *WakuStore) Query(ctx context.Context, query Query, opts ...HistoryRequestOption) (*Result, error) {
        params := new(HistoryRequestParameters)
        params.s = store
    
        optList := DefaultOptions()
    Severity: Major
    Found in waku/v2/protocol/legacy_store/waku_store_client.go - About 55 mins to fix

      Method Pairing.responderHandshake has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
      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: Minor
      Found in waku/v2/protocol/noise/pairing.go - About 55 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 WakuFilterLightNode.onRequest has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
      Open

      func (wf *WakuFilterLightNode) onRequest(ctx context.Context) func(network.Stream) {
          return func(stream network.Stream) {
              peerID := stream.Conn().RemotePeer()
      
              logger := wf.log.With(logging.HostID("peerID", peerID))
      Severity: Minor
      Found in waku/v2/protocol/filter/client.go - About 55 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 9 return statements (exceeds 4 allowed).
      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: Major
      Found in waku/v2/payload/waku_payload.go - About 55 mins to fix

        Function NewMessageSentCheck has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        func NewMessageSentCheck(ctx context.Context, messageVerifier StorenodeMessageVerifier, cycle *history.StorenodeCycle, timesource timesource.Timesource, msgStoredChan chan common.Hash, msgExpiredChan chan common.Hash, logger *zap.Logger) *MessageSentCheck {
        Severity: Major
        Found in waku/v2/api/publish/message_check.go - About 50 mins to fix

          Function WithDynamicRLNRelay has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          func WithDynamicRLNRelay(keystorePath string, keystorePassword string, treePath string, membershipContract common.Address, membershipIndex *uint, spamHandler rln.SpamHandler, ethClientAddress string) WakuNodeOption {
          Severity: Major
          Found in waku/v2/node/wakuoptions_rln.go - About 50 mins to fix

            Function updateLocalNode has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            func updateLocalNode(localnode *enode.LocalNode, multiaddrs []ma.Multiaddr, ipAddr *net.TCPAddr, udpPort uint, wakuFlags WakuEnrBitfield, advertiseAddr *net.IP, shouldAutoUpdate bool) error {
            Severity: Major
            Found in waku/v2/protocol/enr/enr_test.go - About 50 mins to fix

              Method WakuNode.updateLocalNode has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func (w *WakuNode) updateLocalNode(localnode *enode.LocalNode, multiaddrs []ma.Multiaddr, ipAddr *net.TCPAddr, udpPort uint, wakuFlags wenr.WakuEnrBitfield, advertiseAddr []ma.Multiaddr, shouldAutoUpdate bool) error {
              Severity: Major
              Found in waku/v2/node/localnode.go - About 50 mins to fix

                Function waku_lightpush_publish has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                func waku_lightpush_publish(ctx unsafe.Pointer, messageJSON *C.char, topic *C.char, peerID *C.char, ms C.int, cb C.WakuCallBack, userData unsafe.Pointer) C.int {
                Severity: Major
                Found in library/c/api_lightpush.go - About 50 mins to fix

                  Function NewWakuPeerExchange has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  func NewWakuPeerExchange(disc *discv5.DiscoveryV5, clusterID uint16, peerConnector PeerConnector, pm *peermanager.PeerManager, reg prometheus.Registerer, log *zap.Logger, opts ...Option) (*WakuPeerExchange, error) {
                  Severity: Major
                  Found in waku/v2/protocol/peer_exchange/protocol.go - About 50 mins to fix

                    Function save has 8 return statements (exceeds 4 allowed).
                    Open

                    func save(keystore *AppKeystore, path string) error {
                        // We first backup the current keystore
                        _, err := os.Stat(path)
                        if err == nil {
                            err := os.Rename(path, path+".bkp")
                    Severity: Major
                    Found in waku/v2/protocol/rln/keystore/keystore.go - About 50 mins to fix

                      Method WakuNode.setupRLNRelay has 8 return statements (exceeds 4 allowed).
                      Open

                      func (w *WakuNode) setupRLNRelay() error {
                          var err error
                      
                          if !w.opts.enableRLN {
                              return nil
                      Severity: Major
                      Found in waku/v2/node/wakunode2_rln.go - About 50 mins to fix

                        Function BuildConfig has 8 return statements (exceeds 4 allowed).
                        Open

                        func BuildConfig(ctx context.Context, ethClientAddress string, registryAddress common.Address) (*Config, error) {
                            ethClient, err := ethclient.DialContext(ctx, ethClientAddress)
                            if err != nil {
                                return nil, err
                            }
                        Severity: Major
                        Found in waku/v2/protocol/rln/web3/web3.go - About 50 mins to fix

                          Function execute has 8 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-reliable/exec.go - About 50 mins to fix

                            Function extractIPAddressForENR has 8 return statements (exceeds 4 allowed).
                            Open

                            func extractIPAddressForENR(addr ma.Multiaddr) (*net.TCPAddr, error) {
                                // It's a p2p-circuit address. We shouldnt use these
                                // for building the ENR record default keys
                                _, err := addr.ValueForProtocol(ma.P_CIRCUIT)
                                if err == nil {
                            Severity: Major
                            Found in waku/v2/node/localnode.go - About 50 mins to fix

                              Method WakuStore.Request has 8 return statements (exceeds 4 allowed).
                              Open

                              func (s *WakuStore) Request(ctx context.Context, criteria Criteria, opts ...RequestOption) (Result, error) {
                                  params := new(Parameters)
                              
                                  optList := DefaultOptions()
                                  optList = append(optList, opts...)
                              Severity: Major
                              Found in waku/v2/protocol/store/client.go - About 50 mins to fix

                                Function EncodeAsymmetric has 8 return statements (exceeds 4 allowed).
                                Open

                                func EncodeAsymmetric(messageJSON string, publicKey string, optionalSigningKey string) (string, error) {
                                    msg, err := wakuMessage(messageJSON)
                                    if err != nil {
                                        return "", err
                                    }
                                Severity: Major
                                Found in library/encoding.go - About 50 mins to fix

                                  Function Multiaddress has 8 return statements (exceeds 4 allowed).
                                  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: Major
                                  Found in waku/v2/protocol/enr/enr.go - About 50 mins to fix

                                    Method StoreQueryRequest.Validate has 8 return statements (exceeds 4 allowed).
                                    Open

                                    func (x *StoreQueryRequest) Validate() error {
                                        if x.RequestId == "" {
                                            return errMissingRequestID
                                        }
                                    
                                    
                                    Severity: Major
                                    Found in waku/v2/protocol/store/pb/validation.go - About 50 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language