waku-org/go-waku

View on GitHub

Showing 300 of 401 total issues

Function NewWakuStore has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

func NewWakuStore(p MessageProvider, pm *peermanager.PeerManager, timesource timesource.Timesource, reg prometheus.Registerer, log *zap.Logger) *WakuStore {
Severity: Minor
Found in waku/v2/protocol/legacy_store/waku_store_common.go - About 35 mins to fix

    Method WakuFilterLightNode.request has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    func (wf *WakuFilterLightNode) request(ctx context.Context, requestID []byte,
        reqType pb.FilterSubscribeRequest_FilterSubscribeType, contentFilter protocol.ContentFilter, peerID peer.ID) error {
    Severity: Minor
    Found in waku/v2/protocol/filter/client.go - About 35 mins to fix

      Function NewPairing has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func NewPairing(myStaticKey n.Keypair, myEphemeralKey n.Keypair, opts PairingParameterOption, messenger NoiseMessenger, logger *zap.Logger) (*Pairing, error) {
      Severity: Minor
      Found in waku/v2/protocol/noise/pairing.go - About 35 mins to fix

        Function LightpushPublish has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        func LightpushPublish(instanceID uint, messageJSON string, topic string, peerID string, ms int) string {
        Severity: Minor
        Found in library/mobile/api_lightpush.go - About 35 mins to fix

          Function waku_filter_unsubscribe_all has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

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

            Method WakuFilterFullNode.reply has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            func (wf *WakuFilterFullNode) reply(ctx context.Context, stream network.Stream, request *pb.FilterSubscribeRequest, statusCode int, description ...string) {
            Severity: Minor
            Found in waku/v2/protocol/filter/server.go - About 35 mins to fix

              Function waku_filter_ping has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

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

                Function lightpushPublish has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                func lightpushPublish(instance *WakuInstance, msg *pb.WakuMessage, pubsubTopic string, peerID string, ms int) (string, error) {
                Severity: Minor
                Found in library/lightpush.go - About 35 mins to fix

                  Function waku_encode_symmetric has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  func waku_encode_symmetric(messageJSON *C.char, symmetricKey *C.char, optionalSigningKey *C.char, cb C.WakuCallBack, userData unsafe.Pointer) C.int {
                  Severity: Minor
                  Found in library/c/api_encoding.go - About 35 mins to fix

                    Method Chat._doRequestMissingMessageFromStore has 5 return statements (exceeds 4 allowed).
                    Open

                    func (c *Chat) _doRequestMissingMessageFromStore(messageID string) error {
                        ctx, cancel := context.WithTimeout(c.ctx, 10*time.Second)
                        defer cancel()
                    
                        hash, err := base64.URLEncoding.DecodeString(messageID)
                    Severity: Major
                    Found in examples/chat2-reliable/peer_retrieval.go - About 35 mins to fix

                      Method Chat.publish has 5 return statements (exceeds 4 allowed).
                      Open

                      func (c *Chat) publish(ctx context.Context, message *pb.Message) error {
                          msgBytes, err := proto.Marshal(message)
                          if err != nil {
                              return err
                          }
                      Severity: Major
                      Found in examples/chat2-reliable/chat.go - About 35 mins to fix

                        Method PeerManager.SelectRandom has 5 return statements (exceeds 4 allowed).
                        Open

                        func (pm *PeerManager) SelectRandom(criteria PeerSelectionCriteria) (peer.IDSlice, error) {
                            // @TODO We need to be more strategic about which peers we dial. Right now we just set one on the service.
                            // Ideally depending on the query and our set  of peers we take a subset of ideal peers.
                            // This will require us to check for various factors such as:
                            //  - which topics they track
                        Severity: Major
                        Found in waku/v2/peermanager/peer_selection.go - About 35 mins to fix

                          Method DB.Discover has 5 return statements (exceeds 4 allowed).
                          Open

                          func (db *DB) Discover(ns string, cookie []byte, limit int) ([]dbi.RegistrationRecord, []byte, error) {
                              now := time.Now().Unix()
                          
                              var (
                                  counter int64
                          Severity: Major
                          Found in waku/v2/rendezvous/db.go - About 35 mins to fix

                            Method WakuNode.getENRAddresses has 5 return statements (exceeds 4 allowed).
                            Open

                            func (w *WakuNode) getENRAddresses(ctx context.Context, addrs []ma.Multiaddr) (extAddr *net.TCPAddr, multiaddr []ma.Multiaddr, err error) {
                                extAddr, err = selectMostExternalAddress(addrs)
                                if err != nil {
                                    return nil, nil, err
                                }
                            Severity: Major
                            Found in waku/v2/node/localnode.go - About 35 mins to fix

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

                              func New(path string, appInfo AppInfo, logger *zap.Logger) (*AppKeystore, error) {
                                  logger = logger.Named("rln-keystore")
                              
                                  _, err := os.Stat(path)
                                  if err != nil {
                              Severity: Major
                              Found in waku/v2/protocol/rln/keystore/keystore.go - About 35 mins to fix

                                Method MembershipFetcher.loadOldEvents has 5 return statements (exceeds 4 allowed).
                                Open

                                func (mf *MembershipFetcher) loadOldEvents(ctx context.Context, fromBlock, toBlock uint64, handler RegistrationEventHandler) error {
                                    for ; fromBlock+maxBatchSize < toBlock; fromBlock += maxBatchSize + 1 { // check if the end of the batch is within the toBlock range
                                        t1 := time.Now()
                                        events, err := mf.getEvents(ctx, fromBlock, fromBlock+maxBatchSize)
                                        if err != nil {
                                Severity: Major
                                Found in waku/v2/protocol/rln/group_manager/dynamic/membership_fetcher.go - About 35 mins to fix

                                  Method Chat.requestMessageFromPeer has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func (c *Chat) requestMessageFromPeer(peerID peer.ID, messageID string) (*pb.Message, error) {
                                      ctx, cancel := context.WithTimeout(c.ctx, 30*time.Second)
                                      defer cancel()
                                  
                                      stream, err := c.node.Host().NewStream(ctx, peerID, messageRequestProtocolID)
                                  Severity: Major
                                  Found in examples/chat2-reliable/peer_retrieval.go - About 35 mins to fix

                                    Method DBStore.Query has 5 return statements (exceeds 4 allowed).
                                    Open

                                    func (d *DBStore) Query(query *pb.HistoryQuery) (*pb.Index, []StoredMessage, error) {
                                        start := time.Now()
                                        defer func() {
                                            elapsed := time.Since(start)
                                            d.log.Info(fmt.Sprintf("Loading records from the DB took %s", elapsed))
                                    Severity: Major
                                    Found in waku/persistence/store.go - About 35 mins to fix

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

                                      func (pm *PeerManager) checkAndUpdateTopicHealth(topic *NodeTopicDetails) int {
                                          if topic == nil {
                                              return 0
                                          }
                                      
                                      
                                      Severity: Minor
                                      Found in waku/v2/peermanager/peer_manager.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

                                      Method Chat.publish has 5 return statements (exceeds 4 allowed).
                                      Open

                                      func (c *Chat) publish(ctx context.Context, message string) error {
                                          msg := &pb.Chat2Message{
                                              Timestamp: uint64(c.node.Timesource().Now().Unix()),
                                              Nick:      c.nick,
                                              Payload:   []byte(message),
                                      Severity: Major
                                      Found in examples/chat2/chat.go - About 35 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language