waku-org/go-waku

View on GitHub

Showing 239 of 299 total issues

Function Execute has a Cognitive Complexity of 86 (exceeds 20 allowed). Consider refactoring.
Open

func Execute(options NodeOptions) error {
    // Set encoding for logs (console, json, ...)
    // Note that libp2p reads the encoding from GOLOG_LOG_FMT env var.
    utils.InitLogger(options.LogEncoding, options.LogOutput)

Severity: Minor
Found in cmd/waku/node.go - About 1 day 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 a Cognitive Complexity of 80 (exceeds 20 allowed). Consider refactoring.
Open

func (c *Chat) parseInput() {
    defer c.wg.Done()
    for {
        select {
        case <-c.ctx.Done():
Severity: Minor
Found in examples/chat2/chat.go - About 1 day 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 Execute has 275 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func Execute(options NodeOptions) error {
    // Set encoding for logs (console, json, ...)
    // Note that libp2p reads the encoding from GOLOG_LOG_FMT env var.
    utils.InitLogger(options.LogEncoding, options.LogOutput)

Severity: Major
Found in cmd/waku/node.go - About 1 day to fix

    File wakunode2.go has 746 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package node
    
    import (
        "context"
        "math/rand"
    Severity: Minor
    Found in waku/v2/node/wakunode2.go - About 7 hrs to fix

      Function getFlags has 193 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func getFlags() []cli.Flag {
          // Defaults
          options.Fleet = fleetProd
      
          testCT, err := protocol.NewContentTopic("toy-chat", "3", "mingde", "proto")
      Severity: Major
      Found in examples/chat2/flags.go - About 6 hrs to fix

        Function New has a Cognitive Complexity of 51 (exceeds 20 allowed). Consider refactoring.
        Open

        func New(opts ...WakuNodeOption) (*WakuNode, error) {
            var err error
            params := new(WakuNodeParameters)
            params.libP2POpts = DefaultLibP2POptions
        
        
        Severity: Minor
        Found in waku/v2/node/wakunode2.go - About 5 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

        WakuNode has 39 methods (exceeds 20 allowed). Consider refactoring.
        Open

        type WakuNode struct {
            host       host.Host
            opts       *WakuNodeParameters
            log        *zap.Logger
            timesource timesource.Timesource
        Severity: Minor
        Found in waku/v2/node/wakunode2.go - About 5 hrs to fix

          Function New has 140 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func New(opts ...WakuNodeOption) (*WakuNode, error) {
              var err error
              params := new(WakuNodeParameters)
              params.libP2POpts = DefaultLibP2POptions
          
          
          Severity: Major
          Found in waku/v2/node/wakunode2.go - About 4 hrs to fix

            Function TestStoreClient has 131 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func TestStoreClient(t *testing.T) {
                ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
                defer cancel()
            
                port, err := tests.FindFreePort(t, "", 5)
            Severity: Major
            Found in waku/v2/protocol/store/client_test.go - About 4 hrs to fix

              Function getStoreParams has a Cognitive Complexity of 43 (exceeds 20 allowed). Consider refactoring.
              Open

              func getStoreParams(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: Minor
              Found in cmd/waku/server/rest/store.go - About 4 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 client.go has 578 lines of code (exceeds 500 allowed). Consider refactoring.
              Open

              package filter
              
              import (
                  "context"
                  "encoding/hex"
              Severity: Minor
              Found in waku/v2/protocol/filter/client.go - About 3 hrs to fix

                Method WakuNode.Start has 121 lines of code (exceeds 50 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: Major
                Found in waku/v2/node/wakunode2.go - About 3 hrs to fix

                  WakuPeerstoreImpl has 30 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (ps *WakuPeerstoreImpl) AddAddr(p peer.ID, addr ma.Multiaddr, ttl time.Duration) {
                      ps.peerStore.AddAddr(p, addr, ttl)
                  }
                  Severity: Minor
                  Found in waku/v2/peerstore/inherited.go - About 3 hrs to fix

                    Method WakuStore.Query has a Cognitive Complexity of 40 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (store *WakuStore) Query(ctx context.Context, query Query, opts ...HistoryRequestOption) (*Result, error) {
                        params := new(HistoryRequestParameters)
                        params.s = store
                    
                        optList := DefaultOptions()
                    Severity: Minor
                    Found in waku/v2/protocol/legacy_store/waku_store_client.go - About 3 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 111 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func main() {
                        // Defaults
                        options.LogLevel = "INFO"
                        options.LogEncoding = "console"
                    
                    
                    Severity: Major
                    Found in cmd/waku/main.go - About 3 hrs to fix

                      Function newTestCases has 107 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func newTestCases() []*testCase {
                          return []*testCase{
                              {
                                  description: "SameResponse",
                                  servers:     mockedServers,
                      Severity: Major
                      Found in waku/v2/timesource/ntp_test.go - About 3 hrs to fix

                        Function handleRelayTopics has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func handleRelayTopics(ctx context.Context, wg *sync.WaitGroup, wakuNode *node.WakuNode, pubSubTopicMap map[string][]string) error {
                            for nodeTopic, cTopics := range pubSubTopicMap {
                                nodeTopic := nodeTopic
                                _, err := wakuNode.Relay().Subscribe(ctx, wprotocol.NewContentFilter(nodeTopic, cTopics...), relay.WithoutConsumer())
                                if err != nil {
                        Severity: Minor
                        Found in cmd/waku/relay.go - About 3 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 WakuStore.Query has 105 lines of code (exceeds 50 allowed). Consider refactoring.
                        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 3 hrs to fix

                          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

                            Severity
                            Category
                            Status
                            Source
                            Language