moleculer-go/moleculer

View on GitHub

Showing 77 of 77 total issues

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

      Method EventCatalog.Find has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
      Open

      func (eventCatalog *EventCatalog) Find(name string, groups []string, preferLocal bool, localOnly bool, stg strategy.Strategy) []*EventEntry {
          events, exists := eventCatalog.events.Load(name)
          if !exists {
              return make([]*EventEntry, 0)
          }
      Severity: Minor
      Found in registry/eventCatalog.go - About 1 hr 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 7 locations. Consider refactoring.
      Open

          arrayTransformer{
              "[]float64",
              func(source *interface{}) []interface{} {
                  sourceList := (*source).([]float64)
                  result := make([]interface{}, len(sourceList))
      Severity: Major
      Found in payload/arrayTransformers.go and 6 other locations - About 1 hr to fix
      payload/arrayTransformers.go on lines 34..50
      payload/arrayTransformers.go on lines 51..67
      payload/arrayTransformers.go on lines 68..84
      payload/arrayTransformers.go on lines 85..101
      payload/arrayTransformers.go on lines 102..118
      payload/arrayTransformers.go on lines 136..152

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

      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 7 locations. Consider refactoring.
      Open

          arrayTransformer{
              "[]int64",
              func(source *interface{}) []interface{} {
                  sourceList := (*source).([]int64)
                  result := make([]interface{}, len(sourceList))
      Severity: Major
      Found in payload/arrayTransformers.go and 6 other locations - About 1 hr to fix
      payload/arrayTransformers.go on lines 34..50
      payload/arrayTransformers.go on lines 51..67
      payload/arrayTransformers.go on lines 68..84
      payload/arrayTransformers.go on lines 102..118
      payload/arrayTransformers.go on lines 119..135
      payload/arrayTransformers.go on lines 136..152

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

      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 7 locations. Consider refactoring.
      Open

          arrayTransformer{
              "[]uint64",
              func(source *interface{}) []interface{} {
                  sourceList := (*source).([]uint64)
                  result := make([]interface{}, len(sourceList))
      Severity: Major
      Found in payload/arrayTransformers.go and 6 other locations - About 1 hr to fix
      payload/arrayTransformers.go on lines 34..50
      payload/arrayTransformers.go on lines 51..67
      payload/arrayTransformers.go on lines 68..84
      payload/arrayTransformers.go on lines 85..101
      payload/arrayTransformers.go on lines 102..118
      payload/arrayTransformers.go on lines 119..135

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

      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 7 locations. Consider refactoring.
      Open

          arrayTransformer{
              "[]string",
              func(source *interface{}) []interface{} {
                  sourceList := (*source).([]string)
                  result := make([]interface{}, len(sourceList))
      Severity: Major
      Found in payload/arrayTransformers.go and 6 other locations - About 1 hr to fix
      payload/arrayTransformers.go on lines 51..67
      payload/arrayTransformers.go on lines 68..84
      payload/arrayTransformers.go on lines 85..101
      payload/arrayTransformers.go on lines 102..118
      payload/arrayTransformers.go on lines 119..135
      payload/arrayTransformers.go on lines 136..152

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

      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 7 locations. Consider refactoring.
      Open

          arrayTransformer{
              "[]float32",
              func(source *interface{}) []interface{} {
                  sourceList := (*source).([]float32)
                  result := make([]interface{}, len(sourceList))
      Severity: Major
      Found in payload/arrayTransformers.go and 6 other locations - About 1 hr to fix
      payload/arrayTransformers.go on lines 34..50
      payload/arrayTransformers.go on lines 51..67
      payload/arrayTransformers.go on lines 68..84
      payload/arrayTransformers.go on lines 85..101
      payload/arrayTransformers.go on lines 119..135
      payload/arrayTransformers.go on lines 136..152

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

      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 7 locations. Consider refactoring.
      Open

          arrayTransformer{
              "[]bool",
              func(source *interface{}) []interface{} {
                  sourceList := (*source).([]bool)
                  result := make([]interface{}, len(sourceList))
      Severity: Major
      Found in payload/arrayTransformers.go and 6 other locations - About 1 hr to fix
      payload/arrayTransformers.go on lines 34..50
      payload/arrayTransformers.go on lines 51..67
      payload/arrayTransformers.go on lines 85..101
      payload/arrayTransformers.go on lines 102..118
      payload/arrayTransformers.go on lines 119..135
      payload/arrayTransformers.go on lines 136..152

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

      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 7 locations. Consider refactoring.
      Open

          arrayTransformer{
              "[]int",
              func(source *interface{}) []interface{} {
                  sourceList := (*source).([]int)
                  result := make([]interface{}, len(sourceList))
      Severity: Major
      Found in payload/arrayTransformers.go and 6 other locations - About 1 hr to fix
      payload/arrayTransformers.go on lines 34..50
      payload/arrayTransformers.go on lines 68..84
      payload/arrayTransformers.go on lines 85..101
      payload/arrayTransformers.go on lines 102..118
      payload/arrayTransformers.go on lines 119..135
      payload/arrayTransformers.go on lines 136..152

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

      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

          {
              match: func(obj interface{}) bool {
                  _, valid := obj.(func(moleculer.Context) interface{})
                  return valid
              },
      Severity: Major
      Found in service/service.go and 1 other location - About 1 hr to fix
      service/service.go on lines 976..987

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

      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

          {
              match: func(obj interface{}) bool {
                  _, valid := obj.(func(moleculer.Payload) interface{})
                  return valid
              },
      Severity: Major
      Found in service/service.go and 1 other location - About 1 hr to fix
      service/service.go on lines 948..959

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

      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 ServiceRegistry.RemoteNodeInfoReceived has 64 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (registry *ServiceRegistry) RemoteNodeInfoReceived(message moleculer.Payload) {
          registry.nodeReceivedMutex.Lock()
          defer registry.nodeReceivedMutex.Unlock()
      
          msgMap := message.RawMap()
      Severity: Minor
      Found in registry/registry.go - About 1 hr to fix

        Method TCPTransporter.onGossipResponse has 64 lines of code (exceeds 50 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 1 hr to fix

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

              {
                  match: func(obj interface{}) bool {
                      _, valid := obj.(func(moleculer.Context))
                      return valid
                  },
          Severity: Major
          Found in service/service.go and 1 other location - About 1 hr to fix
          service/service.go on lines 989..1001

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

          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

              {
                  match: func(obj interface{}) bool {
                      _, valid := obj.(func(moleculer.Payload))
                      return valid
                  },
          Severity: Major
          Found in service/service.go and 1 other location - About 1 hr to fix
          service/service.go on lines 961..973

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

          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

          func (broker *ServiceBroker) waitForNode(nodeID string) error {
              start := time.Now()
              for {
                  if broker.registry.KnowNode(nodeID) {
                      break
          Severity: Major
          Found in broker/broker.go and 1 other location - About 1 hr to fix
          broker/broker.go on lines 384..398

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

          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

          func (broker *ServiceBroker) waitAction(action string) error {
              start := time.Now()
              for {
                  if broker.registry.KnowAction(action) {
                      break
          Severity: Major
          Found in broker/broker.go and 1 other location - About 1 hr to fix
          broker/broker.go on lines 401..415

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

          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

              mapTransformer{
                  "map[string]float32",
                  func(source *interface{}) map[string]interface{} {
                      result := make(map[string]interface{}, len((*source).(map[string]float32)))
                      for key, value := range (*source).(map[string]float32) {
          Severity: Major
          Found in payload/mapTransformers.go and 5 other locations - About 1 hr to fix
          payload/mapTransformers.go on lines 34..46
          payload/mapTransformers.go on lines 47..59
          payload/mapTransformers.go on lines 60..72
          payload/mapTransformers.go on lines 73..85
          payload/mapTransformers.go on lines 99..111

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

          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

              mapTransformer{
                  "map[string]int",
                  func(source *interface{}) map[string]interface{} {
                      result := make(map[string]interface{}, len((*source).(map[string]int)))
                      for key, value := range (*source).(map[string]int) {
          Severity: Major
          Found in payload/mapTransformers.go and 5 other locations - About 1 hr to fix
          payload/mapTransformers.go on lines 34..46
          payload/mapTransformers.go on lines 60..72
          payload/mapTransformers.go on lines 73..85
          payload/mapTransformers.go on lines 86..98
          payload/mapTransformers.go on lines 99..111

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

          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