docker/swarmkit

View on GitHub

Showing 1,820 of 1,820 total issues

Method Agent.Leave has 5 return statements (exceeds 4 allowed).
Open

func (a *Agent) Leave(ctx context.Context) error {
    select {
    case <-a.started:
    default:
        return errAgentNotStarted
Severity: Major
Found in agent/agent.go - About 35 mins to fix

    Method nodePlugin.NodeStageVolume has 5 return statements (exceeds 4 allowed).
    Open

    func (np *nodePlugin) NodeStageVolume(ctx context.Context, req *api.VolumeAssignment) error {
        np.mu.Lock()
        defer np.mu.Unlock()
        if !np.staging {
            return nil
    Severity: Major
    Found in agent/csi/plugin/plugin.go - About 35 mins to fix

      Method PayloadContext.secretGetter has 5 return statements (exceeds 4 allowed).
      Open

      func (ctx *PayloadContext) secretGetter(target string) (string, error) {
          if ctx.restrictedSecrets == nil {
              return "", errors.New("secrets unavailable")
          }
      
      
      Severity: Major
      Found in template/context.go - About 35 mins to fix

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

        func loadData(swarmdir, unlockKey string) (*storage.WALData, *raftpb.Snapshot, error) {
            snapDir := filepath.Join(swarmdir, "raft", "snap-v3-encrypted")
            walDir := filepath.Join(swarmdir, "raft", "wal-v3-encrypted")
        
            var (
        Severity: Major
        Found in swarmd/cmd/swarm-rafttool/dump.go - About 35 mins to fix

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

          func GetNetwork(ctx context.Context, c api.ControlClient, input string) (*api.Network, error) {
              // GetService to match via full ID.
              rg, err := c.GetNetwork(ctx, &api.GetNetworkRequest{NetworkID: input})
              if err != nil {
                  // If any error (including NotFound), ListServices to match via full name.
          Severity: Major
          Found in swarmd/cmd/swarmctl/network/common.go - About 35 mins to fix

            Method Network.MarshalToSizedBuffer has 5 return statements (exceeds 4 allowed).
            Open

            func (m *Network) MarshalToSizedBuffer(dAtA []byte) (int, error) {
                i := len(dAtA)
                _ = i
                var l int
                _ = l
            Severity: Major
            Found in api/objects.pb.go - About 35 mins to fix

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

              func (m *Node) MarshalToSizedBuffer(dAtA []byte) (int, error) {
                  i := len(dAtA)
                  _ = i
                  var l int
                  _ = l
              Severity: Minor
              Found in api/objects.pb.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 Volume.MarshalToSizedBuffer has 5 return statements (exceeds 4 allowed).
              Open

              func (m *Volume) MarshalToSizedBuffer(dAtA []byte) (int, error) {
                  i := len(dAtA)
                  _ = i
                  var l int
                  _ = l
              Severity: Major
              Found in api/objects.pb.go - About 35 mins to fix

                Method NetworkSpec.MarshalToSizedBuffer has 5 return statements (exceeds 4 allowed).
                Open

                func (m *NetworkSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) {
                    i := len(dAtA)
                    _ = i
                    var l int
                    _ = l
                Severity: Major
                Found in api/specs.pb.go - About 35 mins to fix

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

                  func GetAndValidateCertificateSubject(certs []tls.Certificate) (pkix.Name, error) {
                      for i := range certs {
                          cert := &certs[i]
                          x509Cert, err := x509.ParseCertificate(cert.Certificate[0])
                          if err != nil {
                  Severity: Major
                  Found in ca/transport.go - About 35 mins to fix

                    Method ConstraintEnforcer.rejectNoncompliantTasks has 5 return statements (exceeds 4 allowed).
                    Open

                    func (ce *ConstraintEnforcer) rejectNoncompliantTasks(node *api.Node) {
                        // If the availability is "drain", the orchestrator will
                        // shut down all tasks.
                        // If the availability is "pause", we shouldn't touch
                        // the tasks on this node.
                    Severity: Major
                    Found in manager/orchestrator/constraintenforcer/constraint_enforcer.go - About 35 mins to fix

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

                      func (t tasksByCreationTimestamp) Less(i, j int) bool {
                          if t[i].Meta.CreatedAt == nil {
                              return true
                          }
                          if t[j].Meta.CreatedAt == nil {
                      Severity: Major
                      Found in manager/orchestrator/taskinit/init.go - About 35 mins to fix

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

                        func (r *Orchestrator) Run(ctx context.Context) error {
                            defer close(r.doneChan)
                        
                            // Watch changes to services and tasks
                            queue := r.store.WatchQueue()
                        Severity: Major
                        Found in manager/orchestrator/replicated/replicated.go - About 35 mins to fix

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

                          func (r *Supervisor) waitRestart(ctx context.Context, oldDelay *delayedStart, cluster *api.Cluster, taskID string) {
                              // Wait for the last restart delay to elapse.
                              select {
                              case <-oldDelay.doneCh:
                              case <-ctx.Done():
                          Severity: Major
                          Found in manager/orchestrator/restart/restart.go - About 35 mins to fix

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

                            func (s *Server) UpdateRootCA(ctx context.Context, cluster *api.Cluster, reconciler *rootRotationReconciler) error {
                                s.mu.Lock()
                                s.joinTokens = cluster.RootCA.JoinTokens.Copy()
                                s.mu.Unlock()
                                rCA := cluster.RootCA.Copy()
                            Severity: Minor
                            Found in ca/server.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

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

                            func ConvertToECPrivateKeyPEM(inPEM []byte) ([]byte, error) {
                                block, _ := pem.Decode(inPEM)
                                if block == nil {
                                    return nil, errors.New("invalid pem bytes")
                                }
                            Severity: Major
                            Found in ca/pkcs8/pkcs8.go - About 35 mins to fix

                              Method Updater.useExistingTask has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                              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: Minor
                              Found in manager/orchestrator/update/updater.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

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

                              func ConvertECPrivateKeyPEM(inPEM []byte) ([]byte, error) {
                                  block, _ := pem.Decode(inPEM)
                                  if block == nil {
                                      return nil, errors.New("invalid pem bytes")
                                  }
                              Severity: Major
                              Found in ca/pkcs8/pkcs8.go - About 35 mins to fix

                                Method SecurityConfig.updateTLSCredentials has 5 return statements (exceeds 4 allowed).
                                Open

                                func (s *SecurityConfig) updateTLSCredentials(certificate *tls.Certificate, issuerInfo *IssuerInfo) error {
                                    certs := []tls.Certificate{*certificate}
                                    clientConfig, err := NewClientTLSConfig(certs, s.rootCA.Pool, ManagerRole)
                                    if err != nil {
                                        return errors.Wrap(err, "failed to create a new client config using the new root CA")
                                Severity: Major
                                Found in ca/config.go - About 35 mins to fix

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

                                  func DownloadRootCA(ctx context.Context, paths CertPaths, token string, connBroker *connectionbroker.Broker) (RootCA, error) {
                                      var rootCA RootCA
                                      // Get a digest for the optional CA hash string that we've been provided
                                      // If we were provided a non-empty string, and it is an invalid hash, return
                                      // otherwise, allow the invalid digest through.
                                  Severity: Major
                                  Found in ca/config.go - About 35 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language