waku-org/go-waku

View on GitHub

Showing 400 of 400 total issues

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

func FilterUnsubscribe(instance *WakuInstance, filterJSON string, peerID string, ms int) error {
    cf, err := toContentFilter(filterJSON)
    if err != nil {
        return err
    }
Severity: Major
Found in library/filter.go - About 45 mins to fix

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

        sub := SimulateSubscription([]*protocol.Envelope{
            protocol.NewEnvelope(msg1, *utils.GetUnixEpoch(), pubsubTopic1),
            protocol.NewEnvelope(msg2, *utils.GetUnixEpoch(), pubsubTopic1),
            protocol.NewEnvelope(msg3, *utils.GetUnixEpoch(), pubsubTopic1),
            protocol.NewEnvelope(msg4, *utils.GetUnixEpoch(), pubsubTopic1),
    Severity: Minor
    Found in waku/v2/protocol/legacy_store/waku_store_protocol_test.go and 1 other location - About 45 mins to fix
    waku/v2/protocol/legacy_store/waku_store_protocol_test.go on lines 225..231

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

    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

        sub := SimulateSubscription([]*protocol.Envelope{
            protocol.NewEnvelope(msg1, *utils.GetUnixEpoch(), pubsubTopic1),
            protocol.NewEnvelope(msg2, *utils.GetUnixEpoch(), pubsubTopic1),
            protocol.NewEnvelope(msg3, *utils.GetUnixEpoch(), pubsubTopic1),
            protocol.NewEnvelope(msg4, *utils.GetUnixEpoch(), pubsubTopic1),
    Severity: Minor
    Found in waku/v2/protocol/legacy_store/waku_store_protocol_test.go and 1 other location - About 45 mins to fix
    waku/v2/protocol/legacy_store/waku_store_protocol_test.go on lines 148..154

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

    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

                    result, err = m.storeQueryWithRetry(interest.ctx, func(ctx context.Context) (common.StoreRequestResult, error) {
                        if err = result.Next(ctx); err != nil {
                            return nil, err
                        }
                        return result, nil
    Severity: Minor
    Found in waku/v2/api/missing/missing_messages.go and 1 other location - About 45 mins to fix
    waku/v2/api/missing/missing_messages.go on lines 257..262

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

    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

            result, err = m.storeQueryWithRetry(interest.ctx, func(ctx context.Context) (common.StoreRequestResult, error) {
                if err = result.Next(ctx); err != nil {
                    return nil, err
                }
                return result, nil
    Severity: Minor
    Found in waku/v2/api/missing/missing_messages.go and 1 other location - About 45 mins to fix
    waku/v2/api/missing/missing_messages.go on lines 330..335

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

    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 ip4 == nil && ip6 != nil && !ip6.IsUnspecified() {
                    localnode.Set(enr.IPv6(ip6))
                    localnode.Set(enr.TCP6(ipAddr.Port))
                } else {
                    localnode.Delete(enr.IPv6{})
    Severity: Minor
    Found in waku/v2/node/localnode.go and 1 other location - About 40 mins to fix
    waku/v2/protocol/enr/enr_test.go on lines 60..66

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

    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 ip4 == nil && ip6 != nil && !ip6.IsUnspecified() {
                localnode.Set(enr.IPv6(ip6))
                localnode.Set(enr.TCP6(ipAddr.Port))
            } else {
                localnode.Delete(enr.IPv6{})
    Severity: Minor
    Found in waku/v2/protocol/enr/enr_test.go and 1 other location - About 40 mins to fix
    waku/v2/node/localnode.go on lines 64..70

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

    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 DynamicGroupManager.loadCredential has 6 return statements (exceeds 4 allowed).
    Open

    func (gm *DynamicGroupManager) loadCredential(ctx context.Context) error {
        if gm.appKeystore == nil {
            gm.log.Warn("no credentials were loaded. Node will only validate messages, but wont be able to generate proofs and attach them to messages")
            return nil
        }
    Severity: Major
    Found in waku/v2/protocol/rln/group_manager/dynamic/dynamic.go - About 40 mins to fix

      Function Execute has 6 return statements (exceeds 4 allowed).
      Open

      func Execute() error {
      
          var cTopic, err = protocol.NewContentTopic("basic-relay", "1", "test", "proto")
          if err != nil {
              fmt.Println("Invalid contentTopic")
      Severity: Major
      Found in examples/basic-relay/main.go - About 40 mins to fix

        Function main has 6 return statements (exceeds 4 allowed).
        Open

        func main() {
            // Removing noisy logs
            lvl, err := logging.LevelFromString("error")
            if err != nil {
                panic(err)
        Severity: Major
        Found in examples/noise/main.go - About 40 mins to fix

          Method AppKeystore.AddMembershipCredentials has 6 return statements (exceeds 4 allowed).
          Open

          func (k *AppKeystore) AddMembershipCredentials(newCredential MembershipCredentials, password string) error {
              credentials, err := k.GetMembershipCredentials(password, &newCredential.TreeIndex, newCredential.MembershipContractInfo)
              if err != nil {
                  return err
              }
          Severity: Major
          Found in waku/v2/protocol/rln/keystore/keystore.go - About 40 mins to fix

            Method DynamicGroupManager.Start has 6 return statements (exceeds 4 allowed).
            Open

            func (gm *DynamicGroupManager) Start(ctx context.Context) error {
                if gm.cancel != nil {
                    return errors.New("already started")
                }
            
            
            Severity: Major
            Found in waku/v2/protocol/rln/group_manager/dynamic/dynamic.go - About 40 mins to fix

              Function Execute has 6 return statements (exceeds 4 allowed).
              Open

              func Execute() error {
              
                  var cTopic, err = protocol.NewContentTopic("basic-light-client", "1", "test", "proto")
                  if err != nil {
                      return errors.New("invalid contentTopic")
              Severity: Major
              Found in examples/basic-light-client/main.go - About 40 mins to fix

                Function generateSecureRandomData has 6 return statements (exceeds 4 allowed).
                Open

                func generateSecureRandomData(length int) ([]byte, error) {
                    x := make([]byte, length)
                    y := make([]byte, length)
                    res := make([]byte, length)
                
                
                Severity: Major
                Found in waku/v2/payload/waku_payload.go - About 40 mins to fix

                  Method WakuLightPush.request has 6 return statements (exceeds 4 allowed).
                  Open

                  func (wakuLP *WakuLightPush) request(ctx context.Context, req *pb.PushRequest, params *lightPushRequestParameters, peerID peer.ID) (*pb.PushResponse, error) {
                  
                      logger := wakuLP.log.With(logging.HostID("peer", peerID))
                  
                      stream, err := wakuLP.h.NewStream(ctx, peerID, LightPushID_v20beta1)
                  Severity: Major
                  Found in waku/v2/protocol/lightpush/waku_lightpush.go - About 40 mins to fix

                    Function SetBootnodes has 6 return statements (exceeds 4 allowed).
                    Open

                    func SetBootnodes(instance *WakuInstance, bootnodes string) error {
                        if err := validateInstance(instance, MustBeStarted); err != nil {
                            return err
                        }
                    
                    
                    Severity: Major
                    Found in library/discovery.go - About 40 mins to fix

                      Function validateAndParse has 6 return statements (exceeds 4 allowed).
                      Open

                      func validateAndParse(input []byte) (*DecodedPayload, error) {
                          end := len(input)
                          if end < 1 {
                              return nil, errors.New("invalid message length")
                          }
                      Severity: Major
                      Found in waku/v2/payload/waku_payload.go - About 40 mins to fix

                        Function DecodeSymmetric has 6 return statements (exceeds 4 allowed).
                        Open

                        func DecodeSymmetric(messageJSON string, symmetricKey string) (string, error) {
                            var msg pb.WakuMessage
                            err := json.Unmarshal([]byte(messageJSON), &msg)
                            if err != nil {
                                return "", err
                        Severity: Major
                        Found in library/encoding.go - About 40 mins to fix

                          Function execute has 6 return statements (exceeds 4 allowed).
                          Open

                          func execute(ctx context.Context) error {
                              rlnInstance, err := rln.NewRLN()
                              if err != nil {
                                  return err
                              }
                          Severity: Major
                          Found in cmd/waku/rlngenerate/command_rln.go - About 40 mins to fix

                            Method WakuMetadata.Connected has 6 return statements (exceeds 4 allowed).
                            Open

                            func (wakuM *WakuMetadata) Connected(n network.Network, cc network.Conn) {
                                go func() {
                                    defer utils.LogOnPanic()
                                    wakuM.log.Debug("peer connected", zap.Stringer("peer", cc.RemotePeer()))
                                    // Metadata verification is done only if a clusterID is specified
                            Severity: Major
                            Found in waku/v2/protocol/metadata/waku_metadata.go - About 40 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language