waku-org/go-waku

View on GitHub

Showing 400 of 400 total issues

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

func (s *FilterTestSuite) TestValidPayloadsASCII() {

    // Subscribe
    s.subscribe(s.TestTopic, s.TestContentTopic, s.FullNodeHost.ID())

Severity: Major
Found in waku/v2/protocol/filter/filter_push_test.go and 5 other locations - About 50 mins to fix
waku/v2/protocol/filter/filter_push_test.go on lines 30..44
waku/v2/protocol/filter/filter_push_test.go on lines 46..60
waku/v2/protocol/filter/filter_push_test.go on lines 62..76
waku/v2/protocol/filter/filter_push_test.go on lines 78..92
waku/v2/protocol/filter/filter_push_test.go on lines 94..108

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

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 6 locations. Consider refactoring.
Open

func (s *FilterTestSuite) TestValidPayloadsBase64() {

    // Subscribe
    s.subscribe(s.TestTopic, s.TestContentTopic, s.FullNodeHost.ID())

Severity: Major
Found in waku/v2/protocol/filter/filter_push_test.go and 5 other locations - About 50 mins to fix
waku/v2/protocol/filter/filter_push_test.go on lines 14..28
waku/v2/protocol/filter/filter_push_test.go on lines 30..44
waku/v2/protocol/filter/filter_push_test.go on lines 62..76
waku/v2/protocol/filter/filter_push_test.go on lines 78..92
waku/v2/protocol/filter/filter_push_test.go on lines 94..108

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

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 6 locations. Consider refactoring.
Open

func (s *FilterTestSuite) TestValidPayloadsUTF8() {

    // Subscribe
    s.subscribe(s.TestTopic, s.TestContentTopic, s.FullNodeHost.ID())

Severity: Major
Found in waku/v2/protocol/filter/filter_push_test.go and 5 other locations - About 50 mins to fix
waku/v2/protocol/filter/filter_push_test.go on lines 14..28
waku/v2/protocol/filter/filter_push_test.go on lines 46..60
waku/v2/protocol/filter/filter_push_test.go on lines 62..76
waku/v2/protocol/filter/filter_push_test.go on lines 78..92
waku/v2/protocol/filter/filter_push_test.go on lines 94..108

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

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

      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

        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 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 WakuPeerExchange.Request has 8 return statements (exceeds 4 allowed).
            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: Major
            Found in waku/v2/protocol/peer_exchange/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 WakuFilterLightNode.IncorrectSubscribe has 8 return statements (exceeds 4 allowed).
                  Open

                  func (wf *WakuFilterLightNode) IncorrectSubscribe(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: Major
                  Found in waku/v2/protocol/filter/filter_proto_ident_test.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

                      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 register has 8 return statements (exceeds 4 allowed).
                        Open

                        func register(ctx context.Context, web3Config *web3.Config, idComm rln.IDCommitment) (rln.MembershipIndex, error) {
                            // check if the contract exists by calling a static function
                            membershipFee, err := getMembershipFee(ctx, web3Config.RLNContract)
                            if err != nil {
                                return 0, err
                        Severity: Major
                        Found in cmd/waku/rlngenerate/web3.go - About 50 mins to fix

                          Method WakuFilterLightNode.request has 8 return statements (exceeds 4 allowed).
                          Open

                          func (wf *WakuFilterLightNode) request(ctx context.Context, requestID []byte,
                              reqType pb.FilterSubscribeRequest_FilterSubscribeType, contentFilter protocol.ContentFilter, peerID peer.ID) error {
                              request := &pb.FilterSubscribeRequest{
                                  RequestId:           hex.EncodeToString(requestID),
                                  FilterSubscribeType: reqType,
                          Severity: Major
                          Found in waku/v2/protocol/filter/client.go - About 50 mins to fix

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

                            func (m UI) View() string {
                                spinnerStr := ""
                                inputStr := ""
                                if m.isSending {
                                    spinnerStr = m.spinner.View() + " Sending message..."
                            Severity: Minor
                            Found in examples/chat2/ui.go and 1 other location - About 50 mins to fix
                            examples/chat2-reliable/ui.go on lines 258..275

                            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

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

                            func (m UI) View() string {
                                spinnerStr := ""
                                inputStr := ""
                                if m.isSending {
                                    spinnerStr = m.spinner.View() + " Sending message..."
                            Severity: Minor
                            Found in examples/chat2-reliable/ui.go and 1 other location - About 50 mins to fix
                            examples/chat2/ui.go on lines 258..275

                            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

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language