waku-org/go-waku

View on GitHub

Showing 400 of 400 total issues

Method Chat.discoverNodes has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
Open

func (c *Chat) discoverNodes(connectionWg *sync.WaitGroup) {
    defer c.wg.Done()
    defer connectionWg.Done()

    <-c.uiReady // wait until UI is ready
Severity: Minor
Found in examples/chat2-reliable/chat.go - About 55 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

Function handleNWakuPreMigration has 9 return statements (exceeds 4 allowed).
Open

func handleNWakuPreMigration(db *sql.DB) (bool, error) {
    // Check if there's an user version in the DB, and if migration table does not exist.
    // Rename existing table, and move data afterwards

    var nwakuDBVersion int
Severity: Major
Found in waku/persistence/sqlite/nwaku.go - About 55 mins to fix

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

    func (c *Chat) parseInput() {
        defer c.wg.Done()
        for {
            select {
            case <-c.ctx.Done():
    Severity: Major
    Found in examples/chat2/chat.go - About 55 mins to fix

      Method WakuMetadata.Connected has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
      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: Minor
      Found in waku/v2/protocol/metadata/waku_metadata.go - About 55 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

      Function getLegacyStoreParams has 9 return statements (exceeds 4 allowed).
      Open

      func getLegacyStoreParams(r *http.Request) (*legacy_store.Query, []legacy_store.HistoryRequestOption, error) {
          query := &legacy_store.Query{}
          var options []legacy_store.HistoryRequestOption
          var err error
          peerAddrStr := r.URL.Query().Get("peerAddr")
      Severity: Major
      Found in cmd/waku/server/rest/legacy_store.go - About 55 mins to fix

        Method WakuStore.Query has 9 return statements (exceeds 4 allowed).
        Open

        func (store *WakuStore) Query(ctx context.Context, query Query, opts ...HistoryRequestOption) (*Result, error) {
            params := new(HistoryRequestParameters)
            params.s = store
        
            optList := DefaultOptions()
        Severity: Major
        Found in waku/v2/protocol/legacy_store/waku_store_client.go - About 55 mins to fix

          Method Pairing.responderHandshake has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
          Open

          func (p *Pairing) responderHandshake(ctx context.Context, msgCh <-chan *pb.WakuMessage) (doneCh chan error) {
              doneCh = make(chan error, 1)
          
              func() {
                  defer close(doneCh)
          Severity: Minor
          Found in waku/v2/protocol/noise/pairing.go - About 55 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 WakuFilterLightNode.onRequest has a Cognitive Complexity of 24 (exceeds 20 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 55 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

          Function DecodePayload has 9 return statements (exceeds 4 allowed).
          Open

          func DecodePayload(message *pb.WakuMessage, keyInfo *KeyInfo) (*DecodedPayload, error) {
              switch message.GetVersion() {
              case uint32(0):
                  return &DecodedPayload{Data: message.Payload}, nil
              case uint32(1):
          Severity: Major
          Found in waku/v2/payload/waku_payload.go - About 55 mins to fix

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

                        t.queryResponses[newResponseKey] = queryResponse{
                            contentTopics: topicBatch,
                            messages: []*pb.WakuMessageKeyValue{
                                {
                                    MessageHash: protocol.GenerateRequestID(),
            Severity: Minor
            Found in waku/v2/api/history/history_test.go and 1 other location - About 55 mins to fix
            waku/v2/api/history/history_test.go on lines 142..156

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

            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

                    t.queryResponses[initialResponseKey] = queryResponse{
                        contentTopics: topicBatch,
                        messages: []*pb.WakuMessageKeyValue{
                            {
                                MessageHash: protocol.GenerateRequestID(),
            Severity: Minor
            Found in waku/v2/api/history/history_test.go and 1 other location - About 55 mins to fix
            waku/v2/api/history/history_test.go on lines 168..182

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

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

            func NewMessageSentCheck(ctx context.Context, messageVerifier StorenodeMessageVerifier, cycle *history.StorenodeCycle, timesource timesource.Timesource, msgStoredChan chan common.Hash, msgExpiredChan chan common.Hash, logger *zap.Logger) *MessageSentCheck {
            Severity: Major
            Found in waku/v2/api/publish/message_check.go - About 50 mins to fix

              Function WithDynamicRLNRelay has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func WithDynamicRLNRelay(keystorePath string, keystorePassword string, treePath string, membershipContract common.Address, membershipIndex *uint, spamHandler rln.SpamHandler, ethClientAddress string) WakuNodeOption {
              Severity: Major
              Found in waku/v2/node/wakuoptions_rln.go - About 50 mins to fix

                Function updateLocalNode has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                func updateLocalNode(localnode *enode.LocalNode, multiaddrs []ma.Multiaddr, ipAddr *net.TCPAddr, udpPort uint, wakuFlags WakuEnrBitfield, advertiseAddr *net.IP, shouldAutoUpdate bool) error {
                Severity: Major
                Found in waku/v2/protocol/enr/enr_test.go - About 50 mins to fix

                  Method WakuNode.updateLocalNode has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  func (w *WakuNode) updateLocalNode(localnode *enode.LocalNode, multiaddrs []ma.Multiaddr, ipAddr *net.TCPAddr, udpPort uint, wakuFlags wenr.WakuEnrBitfield, advertiseAddr []ma.Multiaddr, shouldAutoUpdate bool) error {
                  Severity: Major
                  Found in waku/v2/node/localnode.go - About 50 mins to fix

                    Function waku_lightpush_publish has 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    func waku_lightpush_publish(ctx unsafe.Pointer, messageJSON *C.char, topic *C.char, peerID *C.char, ms C.int, cb C.WakuCallBack, userData unsafe.Pointer) C.int {
                    Severity: Major
                    Found in library/c/api_lightpush.go - About 50 mins to fix

                      Function NewWakuPeerExchange has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      func NewWakuPeerExchange(disc *discv5.DiscoveryV5, clusterID uint16, peerConnector PeerConnector, pm *peermanager.PeerManager, reg prometheus.Registerer, log *zap.Logger, opts ...Option) (*WakuPeerExchange, error) {
                      Severity: Major
                      Found in waku/v2/protocol/peer_exchange/protocol.go - About 50 mins to fix

                        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) TestValidPayloadsURLEncoded() {
                        
                            // 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 46..60
                        waku/v2/protocol/filter/filter_push_test.go on lines 62..76
                        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

                        Severity
                        Category
                        Status
                        Source
                        Language