waku-org/go-waku

View on GitHub

Showing 244 of 303 total issues

Function TestSubscriptionsNotify has 101 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func TestSubscriptionsNotify(t *testing.T) {
    fmap := NewSubscriptionMap(utils.Logger())
    p1 := createPeerID(t)
    p2 := createPeerID(t)
    var subscriptions = []*SubscriptionDetails{
Severity: Major
Found in waku/v2/protocol/subscription/subscriptions_map_test.go - About 3 hrs to fix

    Method WakuNode.Start has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
    Open

    func (w *WakuNode) Start(ctx context.Context) error {
        connGater := peermanager.NewConnectionGater(w.opts.maxConnectionsPerIP, w.log)
    
        ctx, cancel := context.WithCancel(ctx)
        w.cancel = cancel
    Severity: Minor
    Found in waku/v2/node/wakunode2.go - About 2 hrs 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 TestFilterGetMessages has 97 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func TestFilterGetMessages(t *testing.T) {
        pubsubTopic := "/waku/2/test/proto"
        contentTopic := "/waku/2/app/1"
    
        // get nodes add connect them
    Severity: Major
    Found in cmd/waku/server/rest/filter_test.go - About 2 hrs to fix

      Function NewNode has 94 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func NewNode(instance *WakuInstance, configJSON string) error {
          if err := validateInstance(instance, NotConfigured); err != nil {
              return err
          }
      
      
      Severity: Major
      Found in library/node.go - About 2 hrs to fix

        Method WakuFilterLightNode.Unsubscribe has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
        Open

        func (wf *WakuFilterLightNode) Unsubscribe(ctx context.Context, contentFilter protocol.ContentFilter, opts ...FilterSubscribeOption) (*WakuFilterPushResult, error) {
            wf.RLock()
            defer wf.RUnlock()
            if err := wf.ErrOnNotRunning(); err != nil {
                return nil, err
        Severity: Minor
        Found in waku/v2/protocol/filter/client.go - About 2 hrs 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

        File flags.go has 526 lines of code (exceeds 500 allowed). Consider refactoring.
        Open

        package main
        
        import (
            "time"
        
        
        Severity: Minor
        Found in cmd/waku/flags.go - About 2 hrs to fix

          Method WakuNode.watchTopicShards has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
          Open

          func (w *WakuNode) watchTopicShards(ctx context.Context) error {
              evtRelaySubscribed, err := w.Relay().Events().Subscribe(new(relay.EvtRelaySubscribed))
              if err != nil {
                  return err
              }
          Severity: Minor
          Found in waku/v2/node/localnode.go - About 2 hrs 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 Chat.parseInput has 88 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

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

            WakuRelay has 23 methods (exceeds 20 allowed). Consider refactoring.
            Open

            type WakuRelay struct {
                host                host.Host
                relayParams         *relayParameters
                pubsub              *pubsub.PubSub
                params              pubsub.GossipSubParams
            Severity: Minor
            Found in waku/v2/protocol/relay/waku_relay.go - About 2 hrs to fix

              Function Test500 has 86 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func Test500(t *testing.T) {
                  maxMsgs := 500
                  maxMsgBytes := int2Bytes(maxMsgs)
              
                  ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
              Severity: Major
              Found in waku/v2/node/wakunode2_test.go - About 2 hrs to fix

                Function getGossipSubParams has 86 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func getGossipSubParams(cfg *GossipSubParams) pubsub.GossipSubParams {
                    params := pubsub.DefaultGossipSubParams()
                
                    if cfg.D != nil {
                        params.D = *cfg.D
                Severity: Major
                Found in library/config.go - About 2 hrs to fix

                  Function getLegacyStoreParams has 85 lines of code (exceeds 50 allowed). Consider refactoring.
                  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 2 hrs to fix

                    Function NewNode has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func NewNode(instance *WakuInstance, configJSON string) error {
                        if err := validateInstance(instance, NotConfigured); err != nil {
                            return err
                        }
                    
                    
                    Severity: Minor
                    Found in library/node.go - About 2 hrs 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 main has 81 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func main() {
                        hostAddr1, _ := net.ResolveTCPAddr("tcp", "0.0.0.0:60000")
                        hostAddr2, _ := net.ResolveTCPAddr("tcp", "0.0.0.0:60001")
                    
                        key1, err := randomHex(32)
                    Severity: Major
                    Found in examples/filter2/main.go - About 2 hrs to fix

                      Function TestPairingObj1Success has 80 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func TestPairingObj1Success(t *testing.T) {
                          host1, relay1 := createRelayNode(t)
                          host2, relay2 := createRelayNode(t)
                      
                          defer host1.Close()
                      Severity: Major
                      Found in waku/v2/protocol/noise/pairing_test.go - About 2 hrs to fix

                        PeerManager has 21 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                        type PeerManager struct {
                            peerConnector          *PeerConnectionStrategy
                            metadata               *metadata.WakuMetadata
                            maxPeers               int
                            maxRelayPeers          int
                        Severity: Minor
                        Found in waku/v2/peermanager/peer_manager.go - About 2 hrs to fix

                          Method WakuFilterLightNode.Unsubscribe has 79 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (wf *WakuFilterLightNode) Unsubscribe(ctx context.Context, contentFilter protocol.ContentFilter, opts ...FilterSubscribeOption) (*WakuFilterPushResult, error) {
                              wf.RLock()
                              defer wf.RUnlock()
                              if err := wf.ErrOnNotRunning(); err != nil {
                                  return nil, err
                          Severity: Major
                          Found in waku/v2/protocol/filter/client.go - About 2 hrs to fix

                            Method Pairing.initiatorHandshake has 78 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (p *Pairing) initiatorHandshake(ctx context.Context, msgCh <-chan *pb.WakuMessage) (doneCh chan error) {
                                doneCh = make(chan error, 1)
                            
                                go func() {
                                    defer close(doneCh)
                            Severity: Major
                            Found in waku/v2/protocol/noise/pairing.go - About 2 hrs to fix

                              Method UI.Update has 78 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func (m UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
                                  var (
                                      tiCmd tea.Cmd
                                      vpCmd tea.Cmd
                                  )
                              Severity: Major
                              Found in examples/chat2/ui.go - About 2 hrs to fix

                                Method onCreate has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    override fun onCreate(savedInstanceState: Bundle?) {
                                        super.onCreate(savedInstanceState)
                                        setContentView(R.layout.activity_main)
                                
                                        val lbl = findViewById<TextView>(R.id.lbl)
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language