docker/swarmkit

View on GitHub

Showing 1,820 of 1,820 total issues

Method StoreSnapshot.CopyFrom has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
Open

func (m *StoreSnapshot) CopyFrom(src interface{}) {

    o := src.(*StoreSnapshot)
    *m = *o
    if o.Nodes != nil {
Severity: Minor
Found in api/snapshot.pb.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

Method LogAttr.Unmarshal has 21 return statements (exceeds 4 allowed).
Open

func (m *LogAttr) Unmarshal(dAtA []byte) error {
    l := len(dAtA)
    iNdEx := 0
    for iNdEx < l {
        preIndex := iNdEx
Severity: Major
Found in api/logbroker.pb.go - About 1 hr to fix

    Method ContainerSpec_Ulimit.Unmarshal has 21 return statements (exceeds 4 allowed).
    Open

    func (m *ContainerSpec_Ulimit) Unmarshal(dAtA []byte) error {
        l := len(dAtA)
        iNdEx := 0
        for iNdEx < l {
            preIndex := iNdEx
    Severity: Major
    Found in api/specs.pb.go - About 1 hr to fix

      Method Allocator.allocateNode has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
      Open

      func (a *Allocator) allocateNode(ctx context.Context, node *api.Node, existingAddressesOnly bool, networks []*api.Network) bool {
          var allocated bool
      
          nc := a.netCtx
      
      
      Severity: Minor
      Found in manager/allocator/network.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

      Method MemoryStore.update has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
      Open

      func (s *MemoryStore) update(proposer state.Proposer, cb func(Tx) error) error {
          defer metrics.StartTimer(updateLatencyTimer)()
          s.updateLock.Lock()
          memDBTx := s.memDB.Txn(true)
      
      
      Severity: Minor
      Found in manager/state/store/memory.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

      Method portAllocator.isPortsAllocatedOnInit has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
      Open

      func (pa *portAllocator) isPortsAllocatedOnInit(s *api.Service, onInit bool) bool {
          // If service has no user-defined endpoint and allocated endpoint,
          // we assume it is allocated and return true.
          if s.Endpoint == nil && s.Spec.Endpoint == nil {
              return true
      Severity: Minor
      Found in manager/allocator/portallocator.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 2 locations. Consider refactoring.
      Open

          if len(m.DriverAttachmentOpts) > 0 {
              for k := range m.DriverAttachmentOpts {
                  v := m.DriverAttachmentOpts[k]
                  baseI := i
                  i -= len(v)
      Severity: Major
      Found in api/objects.pb.go and 1 other location - About 1 hr to fix
      api/specs.pb.go on lines 3157..3175

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

      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 len(m.Labels) > 0 {
              for k := range m.Labels {
                  v := m.Labels[k]
                  baseI := i
                  i -= len(v)
      Severity: Major
      Found in api/specs.pb.go and 1 other location - About 1 hr to fix
      api/objects.pb.go on lines 2013..2031

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

      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 StoreSnapshot.CopyFrom has 72 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (m *StoreSnapshot) CopyFrom(src interface{}) {
      
          o := src.(*StoreSnapshot)
          *m = *o
          if o.Nodes != nil {
      Severity: Minor
      Found in api/snapshot.pb.go - About 1 hr to fix

        Method Supervisor.DelayStart has 72 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (r *Supervisor) DelayStart(ctx context.Context, _ store.Tx, oldTask *api.Task, newTaskID string, delay time.Duration, waitStop bool) <-chan struct{} {
            ctx, cancel := context.WithCancel(context.Background())
            doneCh := make(chan struct{})
        
            r.mu.Lock()
        Severity: Minor
        Found in manager/orchestrator/restart/restart.go - About 1 hr to fix

          Method Manager.handleVolume has 72 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (vm *Manager) handleVolume(ctx context.Context, id string) error {
              var volume *api.Volume
              vm.store.View(func(tx store.ReadTx) {
                  volume = store.GetVolume(tx, id)
              })
          Severity: Minor
          Found in manager/csi/manager.go - About 1 hr to fix

            Method Allocator.allocateTasks has 71 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (a *Allocator) allocateTasks(ctx context.Context, existingAddressesOnly bool) error {
                var (
                    nc             = a.netCtx
                    tasks          []*api.Task
                    allocatedTasks []*api.Task
            Severity: Minor
            Found in manager/allocator/network.go - About 1 hr to fix

              Function Do has 20 return statements (exceeds 4 allowed).
              Open

              func Do(ctx context.Context, task *api.Task, ctlr Controller) (*api.TaskStatus, error) {
                  status := task.Status.Copy()
              
                  // stay in the current state.
                  noop := func(errs ...error) (*api.TaskStatus, error) {
              Severity: Major
              Found in agent/exec/controller.go - About 1 hr to fix

                Method Server.ListNodes has 20 return statements (exceeds 4 allowed).
                Open

                func (s *Server) ListNodes(ctx context.Context, request *api.ListNodesRequest) (*api.ListNodesResponse, error) {
                    var (
                        nodes []*api.Node
                        err   error
                    )
                Severity: Major
                Found in manager/controlapi/node.go - About 1 hr to fix

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

                  func (c *logsClient) SubscribeLogs(ctx context.Context, in *SubscribeLogsRequest, opts ...grpc.CallOption) (Logs_SubscribeLogsClient, error) {
                      stream, err := c.cc.NewStream(ctx, &_Logs_serviceDesc.Streams[0], "/docker.swarmkit.v1.Logs/SubscribeLogs", opts...)
                      if err != nil {
                          return nil, err
                      }
                  Severity: Major
                  Found in api/logbroker.pb.go and 4 other locations - About 1 hr to fix
                  api/dispatcher.pb.go on lines 1384..1397
                  api/dispatcher.pb.go on lines 1476..1489
                  api/logbroker.pb.go on lines 1037..1050
                  api/watch.pb.go on lines 1245..1258

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

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

                  func (c *watchClient) Watch(ctx context.Context, in *WatchRequest, opts ...grpc.CallOption) (Watch_WatchClient, error) {
                      stream, err := c.cc.NewStream(ctx, &_Watch_serviceDesc.Streams[0], "/docker.swarmkit.v1.Watch/Watch", opts...)
                      if err != nil {
                          return nil, err
                      }
                  Severity: Major
                  Found in api/watch.pb.go and 4 other locations - About 1 hr to fix
                  api/dispatcher.pb.go on lines 1384..1397
                  api/dispatcher.pb.go on lines 1476..1489
                  api/logbroker.pb.go on lines 924..937
                  api/logbroker.pb.go on lines 1037..1050

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

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

                  func (c *dispatcherClient) Session(ctx context.Context, in *SessionRequest, opts ...grpc.CallOption) (Dispatcher_SessionClient, error) {
                      stream, err := c.cc.NewStream(ctx, &_Dispatcher_serviceDesc.Streams[0], "/docker.swarmkit.v1.Dispatcher/Session", opts...)
                      if err != nil {
                          return nil, err
                      }
                  Severity: Major
                  Found in api/dispatcher.pb.go and 4 other locations - About 1 hr to fix
                  api/dispatcher.pb.go on lines 1476..1489
                  api/logbroker.pb.go on lines 924..937
                  api/logbroker.pb.go on lines 1037..1050
                  api/watch.pb.go on lines 1245..1258

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

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

                  func (c *dispatcherClient) Assignments(ctx context.Context, in *AssignmentsRequest, opts ...grpc.CallOption) (Dispatcher_AssignmentsClient, error) {
                      stream, err := c.cc.NewStream(ctx, &_Dispatcher_serviceDesc.Streams[2], "/docker.swarmkit.v1.Dispatcher/Assignments", opts...)
                      if err != nil {
                          return nil, err
                      }
                  Severity: Major
                  Found in api/dispatcher.pb.go and 4 other locations - About 1 hr to fix
                  api/dispatcher.pb.go on lines 1384..1397
                  api/logbroker.pb.go on lines 924..937
                  api/logbroker.pb.go on lines 1037..1050
                  api/watch.pb.go on lines 1245..1258

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

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

                  func (c *logBrokerClient) ListenSubscriptions(ctx context.Context, in *ListenSubscriptionsRequest, opts ...grpc.CallOption) (LogBroker_ListenSubscriptionsClient, error) {
                      stream, err := c.cc.NewStream(ctx, &_LogBroker_serviceDesc.Streams[0], "/docker.swarmkit.v1.LogBroker/ListenSubscriptions", opts...)
                      if err != nil {
                          return nil, err
                      }
                  Severity: Major
                  Found in api/logbroker.pb.go and 4 other locations - About 1 hr to fix
                  api/dispatcher.pb.go on lines 1384..1397
                  api/dispatcher.pb.go on lines 1476..1489
                  api/logbroker.pb.go on lines 924..937
                  api/watch.pb.go on lines 1245..1258

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

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

                  func processIPAMOptions(cmd *cobra.Command) (*api.IPAMOptions, error) {
                      flags := cmd.Flags()
                  
                      var ipamOpts *api.IPAMOptions
                      if flags.Changed("ipam-driver") {
                  Severity: Minor
                  Found in swarmd/cmd/swarmctl/network/create.go - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language