waku-org/go-waku

View on GitHub

Showing 400 of 400 total issues

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

func waku_decode_asymmetric(messageJSON *C.char, privateKey *C.char, cb C.WakuCallBack, userData unsafe.Pointer) C.int {
    return singleFnExecNoCtx(func() (string, error) {
        return library.DecodeAsymmetric(C.GoString(messageJSON), C.GoString(privateKey))
    }, cb, userData)
}
Severity: Minor
Found in library/c/api_encoding.go and 1 other location - About 50 mins to fix
library/c/api_encoding.go on lines 16..20

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 120.

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

                lbl.text =
                    (lbl.text.toString() + ">>> Addresses: " + it.addrs.joinToString(",") + "\n")
examples/android-kotlin/app/src/main/java/com/example/waku/MainActivity.kt on lines 67..68

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 80.

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 NewLocalnode has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

func NewLocalnode(priv *ecdsa.PrivateKey, ipAddr *net.TCPAddr, udpPort int, wakuFlags wenr.WakuEnrBitfield, advertiseAddr *net.IP, log *zap.Logger) (*enode.LocalNode, error) {
Severity: Minor
Found in tests/utils.go - About 45 mins to fix

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

    func NewFilterManager(ctx context.Context, logger *zap.Logger, minPeersPerFilter int, envProcessor EnevelopeProcessor, node *filter.WakuFilterLightNode, opts ...SubscribeOptions) *FilterManager {
    Severity: Minor
    Found in waku/v2/api/filter/filter_manager.go - About 45 mins to fix

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

      func computeOffset(timeQuery ntpQuery, servers []string, allowedFailures int) (time.Duration, error) {
          if len(servers) == 0 {
              return 0, nil
          }
          responses := make(chan queryResponse, len(servers))
      Severity: Major
      Found in waku/v2/timesource/ntp.go - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                        if err := pm.metadata.DisconnectPeerOnShardMismatch(ctx, peerEvt.PeerID); err != nil {
                            return
                        }
        Severity: Major
        Found in waku/v2/peermanager/topic_event_handler.go - About 45 mins to fix

          Method HistoryRetriever.Query has 7 return statements (exceeds 4 allowed).
          Open

          func (hr *HistoryRetriever) Query(
              ctx context.Context,
              criteria store.FilterCriteria,
              storenodeID peer.ID,
              pageLimit uint64,
          Severity: Major
          Found in waku/v2/api/history/history.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 HistoryRetriever.requestStoreMessages has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func (hr *HistoryRetriever) requestStoreMessages(ctx context.Context, peerID peer.ID, criteria store.FilterCriteria, cursor []byte, limit uint64, processEnvelopes bool) ([]byte, int, error) {
              Severity: Minor
              Found in waku/v2/api/history/history.go - About 45 mins to fix

                Method AppKeystore.GetMembershipCredentials has 7 return statements (exceeds 4 allowed).
                Open

                func (k *AppKeystore) GetMembershipCredentials(keystorePassword string, index *rln.MembershipIndex, filterMembershipContract MembershipContractInfo) (*MembershipCredentials, error) {
                    // If there is only one, and index to laod nil, assume 0,
                    // if there is more than one, complain if the index to load is nil
                
                    var key Key
                Severity: Major
                Found in waku/v2/protocol/rln/keystore/keystore.go - About 45 mins to fix

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

                      group []rln.IDCommitment,
                      identityCredential rln.IdentityCredential,
                      index rln.MembershipIndex,
                      rlnInstance *rln.RLN,
                      rootTracker *group_manager.MerkleRootTracker,
                  Severity: Minor
                  Found in waku/v2/protocol/rln/group_manager/static/static.go - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                if err != nil {
                                                    c.ui.ErrorMessage(err)
                                                    return
                                                }
                    Severity: Major
                    Found in examples/chat2-reliable/chat.go - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                  if err != nil {
                                                      c.ui.ErrorMessage(err)
                                                      return
                                                  }
                      Severity: Major
                      Found in examples/chat2/chat.go - About 45 mins to fix

                        Method HistoryRetriever.Query has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            ctx context.Context,
                            criteria store.FilterCriteria,
                            storenodeID peer.ID,
                            pageLimit uint64,
                            shouldProcessNextPage func(int) (bool, uint64),
                        Severity: Minor
                        Found in waku/v2/api/history/history.go - About 45 mins to fix

                          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

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

                            func NewPeerManager(maxConnections int, maxPeers int, metadata *metadata.WakuMetadata, relay *relay.WakuRelay, relayEnabled bool, logger *zap.Logger) *PeerManager {
                            Severity: Minor
                            Found in waku/v2/peermanager/peer_manager.go - About 45 mins to fix

                              Method WakuNode.AddDiscoveredPeer has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              func (w *WakuNode) AddDiscoveredPeer(ID peer.ID, addrs []ma.Multiaddr, origin wps.Origin, pubsubTopics []string, enr *enode.Node, connectNow bool) {
                              Severity: Minor
                              Found in waku/v2/node/wakunode2.go - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                            if _, ok := meshPeersSet[p]; !ok {
                                                                relayPeersSet[p] = struct{}{}
                                                            }
                                Severity: Major
                                Found in waku/v2/node/keepalive.go - About 45 mins to fix

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

                                  func Subscribe(ctx context.Context, wf *filter.WakuFilterLightNode, contentFilter protocol.ContentFilter, config FilterConfig, log *zap.Logger, params *subscribeParameters) (*Sub, error) {
                                  Severity: Minor
                                  Found in waku/v2/api/filter/filter.go - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                        if prevNodeVal == "" {
                                                            w.log.Info("local node enr record", logging.ENode("enr", w.localNode.Node()))
                                                        } else {
                                                            w.log.Info("local node new enr record", logging.ENode("enr", w.localNode.Node()))
                                                        }
                                    Severity: Major
                                    Found in waku/v2/node/wakunode2.go - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language