waku-org/go-waku

View on GitHub

Showing 400 of 400 total issues

Function New has 141 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

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

        if options.Filter.Enable {
            cf := protocol.ContentFilter{
                PubsubTopic:   relay.DefaultWakuTopic,
                ContentTopics: protocol.NewContentTopicSet(options.ContentTopic),
            }
    Severity: Major
    Found in examples/chat2/chat.go and 1 other location - About 4 hrs to fix
    examples/chat2-reliable/chat.go on lines 77..110

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

    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 options.Filter.Enable {
            cf := protocol.ContentFilter{
                PubsubTopic:   relay.DefaultWakuTopic,
                ContentTopics: protocol.NewContentTopicSet(options.ContentTopic),
            }
    Severity: Major
    Found in examples/chat2-reliable/chat.go and 1 other location - About 4 hrs to fix
    examples/chat2/chat.go on lines 63..97

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

    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 TestStoreClient has 134 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

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

      func (m *MessageSentCheck) Start() {
          defer utils.LogOnPanic()
          ticker := time.NewTicker(m.hashQueryInterval)
          defer ticker.Stop()
          for {
      Severity: Minor
      Found in waku/v2/api/publish/message_check.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

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

      package sqlite
      
      import (
          "testing"
      
      
      Severity: Major
      Found in waku/persistence/sqlite/sqlite_test.go and 1 other location - About 4 hrs to fix
      waku/persistence/postgres/postgres_test.go on lines 1..51

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

      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

      //go:build include_postgres_tests
      // +build include_postgres_tests
      
      package postgres
      
      
      Severity: Major
      Found in waku/persistence/postgres/postgres_test.go and 1 other location - About 4 hrs to fix
      waku/persistence/sqlite/sqlite_test.go on lines 1..47

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

      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 getLegacyStoreParams has a Cognitive Complexity of 43 (exceeds 20 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: Minor
      Found in cmd/waku/server/rest/legacy_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

      Method WakuNode.Start has 127 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 4 hrs to fix

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

                        if line == "/peers" {
                            peers := c.node.Host().Network().Peers()
                            if len(peers) == 0 {
                                c.ui.InfoMessage("No peers available")
                            } else {
        Severity: Major
        Found in examples/chat2/chat.go and 1 other location - About 4 hrs to fix
        examples/chat2-reliable/chat.go on lines 226..255

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

        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 line == "/peers" {
                            peers := c.node.Host().Network().Peers()
                            if len(peers) == 0 {
                                c.ui.InfoMessage("No peers available")
                            } else {
        Severity: Major
        Found in examples/chat2-reliable/chat.go and 1 other location - About 4 hrs to fix
        examples/chat2/chat.go on lines 204..233

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

        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 WakuNode.Start has a Cognitive Complexity of 42 (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 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

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

                if err != nil {
                    c.ui.ErrorMessage(errors.New(err.Error()))
                } else {
                    var nodeList []peer.AddrInfo
                    for _, n := range nodes {
        Severity: Major
        Found in examples/chat2-reliable/chat.go and 1 other location - About 3 hrs to fix
        examples/chat2/chat.go on lines 508..533

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

        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

                if err != nil {
                    c.ui.ErrorMessage(errors.New(err.Error()))
                } else {
                    var nodeList []peer.AddrInfo
                    for _, n := range nodes {
        Severity: Major
        Found in examples/chat2/chat.go and 1 other location - About 3 hrs to fix
        examples/chat2-reliable/chat.go on lines 522..545

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

        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 MissingMessageVerifier.fetchMessagesBatch has 119 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (m *MissingMessageVerifier) fetchMessagesBatch(c chan<- *protocol.Envelope, interest criteriaInterest, batchFrom int, batchTo int, now time.Time) error {
            contentTopics := interest.contentFilter.ContentTopics.ToList()
        
            logger := m.logger.With(
                zap.Stringer("peerID", interest.peerID),
        Severity: Major
        Found in waku/v2/api/missing/missing_messages.go - About 3 hrs to fix

          Method HistoryRetriever.Query has 119 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (hr *HistoryRetriever) Query(
              ctx context.Context,
              criteria store.FilterCriteria,
              storenodeID peer.ID,
              pageLimit uint64,
          Severity: Major
          Found in waku/v2/api/history/history.go - About 3 hrs to fix

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

            func NewUIModel(readyChan chan<- struct{}, inputChan chan<- string) UI {
                width, height := GetTerminalDimensions()
            
                ta := textarea.New()
                ta.Placeholder = "Send a message..."
            Severity: Major
            Found in examples/chat2/ui.go and 1 other location - About 3 hrs to fix
            examples/chat2-reliable/ui.go on lines 79..115

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

            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 NewUIModel(readyChan chan<- struct{}, inputChan chan<- string) UI {
                width, height := GetTerminalDimensions()
            
                ta := textarea.New()
                ta.Placeholder = "Send a message..."
            Severity: Major
            Found in examples/chat2-reliable/ui.go and 1 other location - About 3 hrs to fix
            examples/chat2/ui.go on lines 79..115

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

            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

            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

              Severity
              Category
              Status
              Source
              Language