moleculer-go/moleculer

View on GitHub

Showing 37 of 77 total issues

Function createNodeService has a Cognitive Complexity of 127 (exceeds 20 allowed). Consider refactoring.
Open

func createNodeService(registry *ServiceRegistry) *service.Service {
    var startedTime time.Time
    isAvailable := func(nodeID string) bool {
        node, exists := registry.nodes.findNode(nodeID)
        return exists && node.IsAvailable()
Severity: Minor
Found in registry/nodeService.go - About 2 days 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 mergeConfigs has a Cognitive Complexity of 90 (exceeds 20 allowed). Consider refactoring.
Open

func mergeConfigs(baseConfig moleculer.Config, userConfig []*moleculer.Config) moleculer.Config {
    if len(userConfig) > 0 {
        for _, config := range userConfig {
            if config.Services != nil {
                baseConfig.Services = mergeMaps(baseConfig.Services, config.Services)
Severity: Minor
Found in broker/broker.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

File service.go has 845 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package service

import (
    "errors"
    "fmt"
Severity: Major
Found in service/service.go - About 1 day to fix

    Function createNodeService has 249 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func createNodeService(registry *ServiceRegistry) *service.Service {
        var startedTime time.Time
        isAvailable := func(nodeID string) bool {
            node, exists := registry.nodes.findNode(nodeID)
            return exists && node.IsAvailable()
    Severity: Major
    Found in registry/nodeService.go - About 1 day to fix

      RawPayload has 46 methods (exceeds 20 allowed). Consider refactoring.
      Open

      type RawPayload struct {
          source interface{}
      }
      Severity: Minor
      Found in payload/payload.go - About 6 hrs to fix

        JSONPayload has 44 methods (exceeds 20 allowed). Consider refactoring.
        Open

        type JSONPayload struct {
            result gjson.Result
            logger *log.Entry
        }
        Severity: Minor
        Found in serializer/jsonSerializer.go - About 6 hrs to fix

          PubSub has 42 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type PubSub struct {
              logger               *log.Entry
              transport            transit.Transport
              broker               *moleculer.BrokerDelegates
              isConnected          bool
          Severity: Minor
          Found in transit/pubsub/pubsub.go - About 5 hrs to fix

            File pubsub.go has 646 lines of code (exceeds 500 allowed). Consider refactoring.
            Open

            package pubsub
            
            import (
                "errors"
                "fmt"
            Severity: Minor
            Found in transit/pubsub/pubsub.go - About 5 hrs to fix

              Method TCPTransporter.onGossipRequest has a Cognitive Complexity of 50 (exceeds 20 allowed). Consider refactoring.
              Open

              func (transporter *TCPTransporter) onGossipRequest(msgBytes *[]byte) {
                  payload := transporter.serializer.BytesToPayload(msgBytes)
                  sender := payload.Get("sender").String()
              
                  transporter.logger.Trace("Received gossip request from " + sender)
              Severity: Minor
              Found in transit/tcp/gossip.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

              ServiceRegistry has 36 methods (exceeds 20 allowed). Consider refactoring.
              Open

              type ServiceRegistry struct {
                  logger                     *log.Entry
                  transit                    transit.Transit
                  localNode                  moleculer.Node
                  nodes                      *NodeCatalog
              Severity: Minor
              Found in registry/registry.go - About 4 hrs to fix

                ServiceBroker has 34 methods (exceeds 20 allowed). Consider refactoring.
                Open

                type ServiceBroker struct {
                    namespace string
                
                    logger *log.Entry
                
                
                Severity: Minor
                Found in broker/broker.go - About 4 hrs to fix

                  File payload.go has 574 lines of code (exceeds 500 allowed). Consider refactoring.
                  Open

                  package payload
                  
                  import (
                      "errors"
                      "fmt"
                  Severity: Minor
                  Found in payload/payload.go - About 3 hrs to fix

                    File broker.go has 566 lines of code (exceeds 500 allowed). Consider refactoring.
                    Open

                    package broker
                    
                    import (
                        "errors"
                        "strings"
                    Severity: Minor
                    Found in broker/broker.go - About 3 hrs to fix

                      File jsonSerializer.go has 563 lines of code (exceeds 500 allowed). Consider refactoring.
                      Open

                      package serializer
                      
                      import (
                          "bytes"
                          "encoding/json"
                      Severity: Minor
                      Found in serializer/jsonSerializer.go - About 3 hrs to fix

                        Method TCPTransporter.onGossipRequest has 107 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (transporter *TCPTransporter) onGossipRequest(msgBytes *[]byte) {
                            payload := transporter.serializer.BytesToPayload(msgBytes)
                            sender := payload.Get("sender").String()
                        
                            transporter.logger.Trace("Received gossip request from " + sender)
                        Severity: Major
                        Found in transit/tcp/gossip.go - About 3 hrs to fix

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

                          func (transporter *TCPTransporter) onGossipResponse(msgBytes *[]byte) {
                              payload := transporter.serializer.BytesToPayload(msgBytes)
                              sender := payload.Get("sender").String()
                          
                              transporter.logger.Trace("Received gossip response from " + sender)
                          Severity: Minor
                          Found in transit/tcp/gossip.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 mergeConfigs has 92 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func mergeConfigs(baseConfig moleculer.Config, userConfig []*moleculer.Config) moleculer.Config {
                              if len(userConfig) > 0 {
                                  for _, config := range userConfig {
                                      if config.Services != nil {
                                          baseConfig.Services = mergeMaps(baseConfig.Services, config.Services)
                          Severity: Major
                          Found in broker/broker.go - About 2 hrs to fix

                            Context has 24 methods (exceeds 20 allowed). Consider refactoring.
                            Open

                            type Context struct {
                                id           string
                                requestID    string
                                broker       *moleculer.BrokerDelegates
                                targetNodeID string
                            Severity: Minor
                            Found in context/contextFactory.go - About 2 hrs to fix

                              File registry.go has 518 lines of code (exceeds 500 allowed). Consider refactoring.
                              Open

                              package registry
                              
                              import (
                                  "errors"
                                  "fmt"
                              Severity: Minor
                              Found in registry/registry.go - About 2 hrs to fix

                                Service has 22 methods (exceeds 20 allowed). Consider refactoring.
                                Open

                                type Service struct {
                                    nodeID       string
                                    fullname     string
                                    name         string
                                    version      string
                                Severity: Minor
                                Found in service/service.go - About 2 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language