docker/swarmkit

View on GitHub

Showing 1,008 of 1,820 total issues

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

                            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
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language