docker/swarmkit

View on GitHub

Showing 1,008 of 1,820 total issues

Avoid deeply nested control flow statements.
Open

                if packedLen < 0 {
                    return ErrInvalidLengthRaft
                }
Severity: Major
Found in api/raft.pb.go - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                    if postIndex > l {
                        return io.ErrUnexpectedEOF
                    }
    Severity: Major
    Found in api/raft.pb.go - About 45 mins to fix

      Method Orchestrator.addTasks has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func (r *Orchestrator) addTasks(ctx context.Context, batch *store.Batch, service *api.Service, runningSlots map[uint64]orchestrator.Slot, deadSlots map[uint64]orchestrator.Slot, count uint64) {
      Severity: Minor
      Found in manager/orchestrator/replicated/services.go - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if shift >= 64 {
                                return ErrIntOverflowRaft
                            }
        Severity: Major
        Found in api/raft.pb.go - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                          if elementCount != 0 && len(m.RemovedMembers) == 0 {
                              m.RemovedMembers = make([]uint64, 0, elementCount)
                          }
          Severity: Major
          Found in api/raft.pb.go - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                            for iNdEx < postIndex {
                                var v uint64
                                for shift := uint(0); ; shift += 7 {
                                    if shift >= 64 {
                                        return ErrIntOverflowRaft
            Severity: Major
            Found in api/raft.pb.go - About 45 mins to fix

              Method Updater.Run has 7 return statements (exceeds 4 allowed).
              Open

              func (u *Updater) Run(ctx context.Context, slots []orchestrator.Slot) {
                  defer close(u.doneChan)
              
                  service := u.newService
              
              
              Severity: Major
              Found in manager/orchestrator/update/updater.go - About 45 mins to fix

                Method Orchestrator.tickTasks has 7 return statements (exceeds 4 allowed).
                Open

                func (g *Orchestrator) tickTasks(ctx context.Context) {
                    if len(g.restartTasks) == 0 {
                        return
                    }
                    err := g.store.Batch(func(batch *store.Batch) error {
                Severity: Major
                Found in manager/orchestrator/global/global.go - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if err != nil {
                                              log.G(ctx).WithError(err).WithField("task.id", updated.ID).Warning("failed to remove old task after starting replacement")
                                          }
                  Severity: Major
                  Found in manager/orchestrator/update/updater.go - About 45 mins to fix

                    Method Scheduler.scheduleNTasksOnSubtree has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    func (s *Scheduler) scheduleNTasksOnSubtree(ctx context.Context, n int, taskGroup map[string]*api.Task, tree *decisionTree, schedulingDecisions map[string]schedulingDecision, nodeLess func(a *NodeInfo, b *NodeInfo) bool) int {
                    Severity: Minor
                    Found in manager/scheduler/scheduler.go - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                  if status.NodeID == nodeID {
                                                      if assignments.addOrUpdateVolume(readTx, vol) {
                                                          oneModification()
                                                      }
                                                  }
                      Severity: Major
                      Found in manager/dispatcher/dispatcher.go - About 45 mins to fix

                        Method Server.CreateService has 7 return statements (exceeds 4 allowed).
                        Open

                        func (s *Server) CreateService(ctx context.Context, request *api.CreateServiceRequest) (*api.CreateServiceResponse, error) {
                            if err := validateServiceSpec(request.Spec); err != nil {
                                return nil, err
                            }
                        
                        
                        Severity: Major
                        Found in manager/controlapi/service.go - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                          if !request.IncludeOldObject {
                                              eventMessage.OldObject = nil
                                          }
                          Severity: Major
                          Found in manager/watchapi/watch.go - About 45 mins to fix

                            Method Scheduler.updateTask has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                            Open

                            func (s *Scheduler) updateTask(ctx context.Context, t *api.Task) bool {
                                // Ignore all tasks that have not reached PENDING
                                // state.
                                if t.Status.State < api.TaskStatePending {
                                    return false
                            Severity: Minor
                            Found in manager/scheduler/scheduler.go - About 45 mins 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

                            Avoid deeply nested control flow statements.
                            Open

                                                    if assignments.removeTask(readTx, v.Task) {
                                                        oneModification()
                                                    }
                            Severity: Major
                            Found in manager/dispatcher/dispatcher.go - About 45 mins to fix

                              Method Scheduler.scheduleNTasksOnNodes has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              func (s *Scheduler) scheduleNTasksOnNodes(ctx context.Context, n int, taskGroup map[string]*api.Task, nodes []NodeInfo, schedulingDecisions map[string]schedulingDecision, nodeLess func(a *NodeInfo, b *NodeInfo) bool) int {
                              Severity: Minor
                              Found in manager/scheduler/scheduler.go - About 45 mins to fix

                                Function validateConfigRefsSpec has 7 return statements (exceeds 4 allowed).
                                Open

                                func validateConfigRefsSpec(spec api.TaskSpec) error {
                                    container := spec.GetContainer()
                                    if container == nil {
                                        return nil
                                    }
                                Severity: Major
                                Found in manager/controlapi/service.go - About 45 mins to fix

                                  Function watchNode has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                  func watchNode(t *testing.T, watch chan events.Event, expectTimeout bool,
                                      fn func(t assert.TestingT, originalNode, updatedNode *api.Node, networks []string) bool,
                                      originalNode *api.Node,
                                      networks []string) {
                                  Severity: Minor
                                  Found in manager/allocator/allocator_test_suite.go - About 45 mins to fix

                                    Function validateServiceSpec has 7 return statements (exceeds 4 allowed).
                                    Open

                                    func validateServiceSpec(spec *api.ServiceSpec) error {
                                        if spec == nil {
                                            return status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
                                        }
                                        if err := validateAnnotations(spec.Annotations); err != nil {
                                    Severity: Major
                                    Found in manager/controlapi/service.go - About 45 mins to fix

                                      Function newRootRotationObject has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                      func newRootRotationObject(ctx context.Context, securityConfig *ca.SecurityConfig, apiRootCA *api.RootCA, newCARootCA ca.RootCA, extCAs []*api.ExternalCA, version uint64) (*api.RootCA, error) {
                                      Severity: Minor
                                      Found in manager/controlapi/ca_rotation.go - About 45 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language