waku-org/go-waku

View on GitHub

Showing 400 of 400 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    go func() {
        defer wg.Done()

        ticker := time.NewTimer(30 * time.Second)
        defer ticker.Stop()
Severity: Major
Found in waku/v2/node/wakunode2_test.go and 1 other location - About 1 hr to fix
waku/v2/node/wakunode2_test.go on lines 193..212

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 138.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    go func() {
        defer wg.Done()

        ticker := time.NewTimer(30 * time.Second)
        defer ticker.Stop()
Severity: Major
Found in waku/v2/node/wakunode2_test.go and 1 other location - About 1 hr to fix
waku/v2/node/wakunode2_test.go on lines 172..191

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 138.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function NewDynamicGroupManager has 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

    ethClientAddr string,
    memContractAddr common.Address,
    membershipIndexToLoad *uint,
    appKeystore *keystore.AppKeystore,
    keystorePassword string,
Severity: Major
Found in waku/v2/protocol/rln/group_manager/dynamic/dynamic.go - About 1 hr to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        if c.options.RLNRelay.Enable {
            err = c.node.RLNRelay().AppendRLNProof(wakuMsg, c.node.Timesource().Now())
            if err != nil {
                return err
            }
    Severity: Major
    Found in examples/chat2-reliable/chat.go and 1 other location - About 1 hr to fix
    examples/chat2/chat.go on lines 310..324

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 136.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        if c.options.RLNRelay.Enable {
            // for future version when we support more than one rln protected content topic,
            // we should check the message content topic as well
            err = c.node.RLNRelay().AppendRLNProof(wakuMsg, c.node.Timesource().Now())
            if err != nil {
    Severity: Major
    Found in examples/chat2/chat.go and 1 other location - About 1 hr to fix
    examples/chat2-reliable/chat.go on lines 333..345

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 136.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method Chat.parseInput has 11 return statements (exceeds 4 allowed).
    Open

    func (c *Chat) parseInput() {
        defer c.wg.Done()
    
        var disconnectedPeers []peer.ID
    
    
    Severity: Major
    Found in examples/chat2-reliable/chat.go - About 1 hr to fix

      Method DB.prepareStmts has 11 return statements (exceeds 4 allowed).
      Open

      func (db *DB) prepareStmts() error {
          stmt, err := db.db.Prepare("INSERT INTO registrations VALUES (NULL, ?, ?, ?, ?)")
          if err != nil {
              return err
          }
      Severity: Major
      Found in waku/v2/rendezvous/db.go - About 1 hr to fix

        Function getStoreParams has 11 return statements (exceeds 4 allowed).
        Open

        func getStoreParams(r *http.Request) (store.Criteria, []store.RequestOption, error) {
            var options []store.RequestOption
            var err error
            peerAddrStr := r.URL.Query().Get("peerAddr")
            var m multiaddr.Multiaddr
        Severity: Major
        Found in cmd/waku/server/rest/store.go - About 1 hr to fix

          Method Chat.publish has 52 lines of code (exceeds 50 allowed). Consider refactoring.
          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: Minor
          Found in examples/chat2/chat.go - About 1 hr to fix

            Function TestWakuLightPushCornerCases has 52 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func TestWakuLightPushCornerCases(t *testing.T) {
                ctx, cancel := context.WithCancel(context.Background())
                defer cancel()
            
                testTopic := "/waku/2/go/lightpush/test"
            Severity: Minor
            Found in waku/v2/protocol/lightpush/waku_lightpush_test.go - About 1 hr to fix

              Method WakuFilterLightNode.onRequest has 52 lines of code (exceeds 50 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 1 hr to fix

                Method DB.prepareStmts has 51 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (db *DB) prepareStmts() error {
                    stmt, err := db.db.Prepare("INSERT INTO registrations VALUES (NULL, ?, ?, ?, ?)")
                    if err != nil {
                        return err
                    }
                Severity: Minor
                Found in waku/v2/rendezvous/db.go - About 1 hr to fix

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

                    Method WakuLightPush.handleOpts has 51 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (wakuLP *WakuLightPush) handleOpts(ctx context.Context, message *wpb.WakuMessage, opts ...RequestOption) (*lightPushRequestParameters, error) {
                        params := new(lightPushRequestParameters)
                        params.host = wakuLP.h
                        params.log = wakuLP.log
                        params.pm = wakuLP.pm
                    Severity: Minor
                    Found in waku/v2/protocol/lightpush/waku_lightpush.go - About 1 hr to fix

                      Function rlnFlags has 51 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func rlnFlags() []cli.Flag {
                          return []cli.Flag{
                              &cli.BoolFlag{
                                  Name:        "rln-relay",
                                  Value:       false,
                      Severity: Minor
                      Found in cmd/waku/flags_rln.go - About 1 hr to fix

                        Method HistoryRetriever.createMessagesRequest has 8 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            ctx context.Context,
                            peerID peer.ID,
                            criteria store.FilterCriteria,
                            cursor []byte,
                            limit uint64,
                        Severity: Major
                        Found in waku/v2/api/history/history.go - About 1 hr to fix

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  if evt.Type == pubsub.PeerJoin {
                                      w.log.Debug("received a PeerJoin event", zap.String("topic", topic), logging.HostID("peerID", evt.Peer))
                                      err = w.emitters.EvtPeerTopic.Emit(EvtPeerTopic{PubsubTopic: topic, PeerID: evt.Peer, State: PEER_JOINED})
                                      if err != nil {
                                          w.log.Error("failed to emit PeerJoin", zap.String("topic", topic), zap.Error(err))
                          Severity: Minor
                          Found in waku/v2/protocol/relay/topic_events.go and 1 other location - About 1 hr to fix
                          waku/v2/protocol/relay/topic_events.go on lines 75..84

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 129.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  } else if evt.Type == pubsub.PeerLeave {
                                      w.log.Debug("received a PeerLeave event", zap.String("topic", topic), logging.HostID("peerID", evt.Peer))
                                      err = w.emitters.EvtPeerTopic.Emit(EvtPeerTopic{PubsubTopic: topic, PeerID: evt.Peer, State: PEER_LEFT})
                                      if err != nil {
                                          w.log.Error("failed to emit PeerLeave", zap.String("topic", topic), zap.Error(err))
                          Severity: Minor
                          Found in waku/v2/protocol/relay/topic_events.go and 1 other location - About 1 hr to fix
                          waku/v2/protocol/relay/topic_events.go on lines 69..84

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 129.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                          func (m UI) breaklineIfNeeded(i int, mt MessageType) string {
                              result := ""
                              if i > 0 {
                                  if (mt == ChatMessageType && m.messages[i-1].mType != ChatMessageType) || (mt != ChatMessageType && m.messages[i-1].mType == ChatMessageType) {
                                      result += "\n"
                          Severity: Minor
                          Found in examples/chat2/ui.go and 1 other location - About 1 hr to fix
                          examples/chat2-reliable/ui.go on lines 235..243

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 128.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                          func (m UI) breaklineIfNeeded(i int, mt MessageType) string {
                              result := ""
                              if i > 0 {
                                  if (mt == ChatMessageType && m.messages[i-1].mType != ChatMessageType) || (mt != ChatMessageType && m.messages[i-1].mType == ChatMessageType) {
                                      result += "\n"
                          Severity: Minor
                          Found in examples/chat2-reliable/ui.go and 1 other location - About 1 hr to fix
                          examples/chat2/ui.go on lines 235..243

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 128.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Severity
                          Category
                          Status
                          Source
                          Language