docker/swarmkit

View on GitHub

Showing 1,820 of 1,820 total issues

Function SetServiceTasksRemove has 5 return statements (exceeds 4 allowed).
Open

func SetServiceTasksRemove(ctx context.Context, s *store.MemoryStore, service *api.Service) {
    var (
        tasks []*api.Task
        err   error
    )
Severity: Major
Found in manager/orchestrator/service.go - About 35 mins to fix

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

    func (r *Orchestrator) tickTasks(ctx context.Context) {
        if len(r.restartTasks) > 0 {
            err := r.store.Batch(func(batch *store.Batch) error {
                for taskID := range r.restartTasks {
                    err := batch.Update(func(tx store.Tx) error {
    Severity: Major
    Found in manager/orchestrator/replicated/tasks.go - About 35 mins to fix

      Method TLSRenewer.Start has 5 return statements (exceeds 4 allowed).
      Open

      func (t *TLSRenewer) Start(ctx context.Context) <-chan CertificateUpdate {
          updates := make(chan CertificateUpdate)
      
          go func() {
              var (
      Severity: Major
      Found in ca/renewer.go - About 35 mins to fix

        Function updateRootThenUpdateCert has 5 return statements (exceeds 4 allowed).
        Open

        func updateRootThenUpdateCert(ctx context.Context, s *SecurityConfig, connBroker *connectionbroker.Broker, rootPaths CertPaths, failedCert *x509.Certificate) (*tls.Certificate, *IssuerInfo, error) {
            if len(failedCert.Subject.OrganizationalUnit) == 0 || failedCert.Subject.OrganizationalUnit[0] != WorkerRole {
                return nil, nil, errors.New("cannot update root CA since this is not a worker")
            }
            // try downloading a new root CA if it's an unknown authority issue, in case there was a root rotation completion
        Severity: Major
        Found in ca/config.go - About 35 mins to fix

          Method Supervisor.UpdatableTasksInSlot has 5 return statements (exceeds 4 allowed).
          Open

          func (r *Supervisor) UpdatableTasksInSlot(ctx context.Context, slot orchestrator.Slot, service *api.Service) orchestrator.Slot {
              if len(slot) < 1 {
                  return nil
              }
          
          
          Severity: Major
          Found in manager/orchestrator/restart/restart.go - About 35 mins to fix

            Method VolumeEnforcer.rejectNoncompliantTasks has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
            Open

            func (ve *VolumeEnforcer) rejectNoncompliantTasks(v *api.Volume) {
                if v.Spec.Availability != api.VolumeAvailabilityDrain {
                    return
                }
            
            
            Severity: Minor
            Found in manager/orchestrator/volumeenforcer/volume_enforcer.go - About 35 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

            Method Dispatcher.register has 5 return statements (exceeds 4 allowed).
            Open

            func (d *Dispatcher) register(ctx context.Context, nodeID string, description *api.NodeDescription) (string, error) {
                logLocal := log.G(ctx).WithField("method", "(*Dispatcher).register")
                // prevent register until we're ready to accept it
                dctx, err := d.isRunningLocked()
                if err != nil {
            Severity: Major
            Found in manager/dispatcher/dispatcher.go - About 35 mins to fix

              Method RaftDEKManager.GetKeys has 5 return statements (exceeds 4 allowed).
              Open

              func (r *RaftDEKManager) GetKeys() raft.EncryptionKeys {
                  var newKeys, originalKeys raft.EncryptionKeys
                  err := r.kw.ViewAndUpdateHeaders(func(h ca.PEMKeyHeaders) (ca.PEMKeyHeaders, error) {
                      data, ok := h.(RaftDEKData)
                      if !ok {
              Severity: Major
              Found in manager/deks.go - About 35 mins to fix

                Method plugin.PublishVolume has 5 return statements (exceeds 4 allowed).
                Open

                func (p *plugin) PublishVolume(ctx context.Context, v *api.Volume, nodeID string) (map[string]string, error) {
                    if !p.publisher {
                        return nil, nil
                    }
                    csiNodeID := p.swarmToCSI[nodeID]
                Severity: Major
                Found in manager/csi/plugin.go - About 35 mins to fix

                  Method TasksByTimestamp.Less has 5 return statements (exceeds 4 allowed).
                  Open

                  func (t TasksByTimestamp) Less(i, j int) bool {
                      iTimestamp := taskTimestamp(t[i])
                      jTimestamp := taskTimestamp(t[j])
                  
                      if iTimestamp == nil {
                  Severity: Major
                  Found in manager/orchestrator/task.go - About 35 mins to fix

                    Method Dispatcher.UpdateTaskStatus has 5 return statements (exceeds 4 allowed).
                    Open

                    func (d *Dispatcher) UpdateTaskStatus(ctx context.Context, r *api.UpdateTaskStatusRequest) (*api.UpdateTaskStatusResponse, error) {
                        d.rpcRW.RLock()
                        defer d.rpcRW.RUnlock()
                    
                        dctx, err := d.isRunningLocked()
                    Severity: Major
                    Found in manager/dispatcher/dispatcher.go - About 35 mins to fix

                      Method Server.RemoveService has 5 return statements (exceeds 4 allowed).
                      Open

                      func (s *Server) RemoveService(ctx context.Context, request *api.RemoveServiceRequest) (*api.RemoveServiceResponse, error) {
                          if request.ServiceID == "" {
                              return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
                          }
                      
                      
                      Severity: Major
                      Found in manager/controlapi/service.go - About 35 mins to fix

                        Method Updater.useExistingTask has 5 return statements (exceeds 4 allowed).
                        Open

                        func (u *Updater) useExistingTask(ctx context.Context, slot orchestrator.Slot, existing *api.Task) error {
                            var removeTasks []*api.Task
                            for _, t := range slot {
                                if t != existing {
                                    removeTasks = append(removeTasks, t)
                        Severity: Major
                        Found in manager/orchestrator/update/updater.go - About 35 mins to fix

                          Method Updater.rollbackUpdate has 5 return statements (exceeds 4 allowed).
                          Open

                          func (u *Updater) rollbackUpdate(ctx context.Context, serviceID, message string) {
                              log.G(ctx).Debugf("starting rollback of service %s", serviceID)
                          
                              err := u.store.Update(func(tx store.Tx) error {
                                  service := store.GetService(tx, serviceID)
                          Severity: Major
                          Found in manager/orchestrator/update/updater.go - About 35 mins to fix

                            Method volumeSet.freeVolumes has 5 return statements (exceeds 4 allowed).
                            Open

                            func (vs *volumeSet) freeVolumes(batch *store.Batch) error {
                                for volumeID, info := range vs.volumes {
                                    if err := batch.Update(func(tx store.Tx) error {
                                        v := store.GetVolume(tx, volumeID)
                                        if v == nil {
                            Severity: Major
                            Found in manager/scheduler/volumes.go - About 35 mins to fix

                              Method Manager.getPlugin has 5 return statements (exceeds 4 allowed).
                              Open

                              func (vm *Manager) getPlugin(name string) (Plugin, error) {
                                  // if the plugin already exists, we can just return it.
                                  if p, ok := vm.plugins[name]; ok {
                                      return p, nil
                                  }
                              Severity: Major
                              Found in manager/csi/manager.go - About 35 mins to fix

                                Method Scheduler.scheduleNTasksOnNodes has a Cognitive Complexity of 22 (exceeds 20 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 {
                                    tasksScheduled := 0
                                    failedConstraints := make(map[int]bool) // key is index in nodes slice
                                    nodeIter := 0
                                    nodeCount := len(nodes)
                                Severity: Minor
                                Found in manager/scheduler/scheduler.go - About 35 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

                                Method Scheduler.scheduleTaskGroup has 5 return statements (exceeds 4 allowed).
                                Open

                                func (s *Scheduler) scheduleTaskGroup(ctx context.Context, taskGroup map[string]*api.Task, schedulingDecisions map[string]schedulingDecision) {
                                    // Pick at task at random from taskGroup to use for constraint
                                    // evaluation. It doesn't matter which one we pick because all the
                                    // tasks in the group are equal in terms of the fields the constraint
                                    // filters consider.
                                Severity: Major
                                Found in manager/scheduler/scheduler.go - About 35 mins to fix

                                  Method PluginFilter.Check has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func (f *PluginFilter) Check(n *NodeInfo) bool {
                                      if n.Description == nil || n.Description.Engine == nil {
                                          // If the node is not running Engine, plugins are not
                                          // supported.
                                          return true
                                  Severity: Major
                                  Found in manager/scheduler/filter.go - About 35 mins to fix

                                    Method Dispatcher.Run has 5 return statements (exceeds 4 allowed).
                                    Open

                                    func (d *Dispatcher) Run(ctx context.Context) error {
                                        ctx = log.WithModule(ctx, "dispatcher")
                                        log.G(ctx).Info("dispatcher starting")
                                    
                                        d.taskUpdatesLock.Lock()
                                    Severity: Major
                                    Found in manager/dispatcher/dispatcher.go - About 35 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language