dotcloud/docker

View on GitHub

Showing 1,468 of 1,914 total issues

Method Cluster.GetService has 5 return statements (exceeds 4 allowed).
Open

func (c *Cluster) GetService(input string, insertDefaults bool) (swarm.Service, error) {
    var service *swarmapi.Service
    if err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
        s, err := getService(ctx, state.controlClient, input, insertDefaults)
        if err != nil {
Severity: Major
Found in daemon/cluster/services.go - About 35 mins to fix

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

    func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) {
        info, err := e.backend.SystemInfo(ctx)
        if err != nil {
            return nil, err
        }
    Severity: Minor
    Found in daemon/cluster/executor/container/executor.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 Cluster.CreateNetwork has 5 return statements (exceeds 4 allowed).
    Open

    func (c *Cluster) CreateNetwork(s network.CreateRequest) (string, error) {
        if networkSettings.IsPredefined(s.Name) {
            err := notAllowedError(fmt.Sprintf("%s is a pre-defined network and cannot be created", s.Name))
            return "", errors.WithStack(err)
        }
    Severity: Major
    Found in daemon/cluster/networks.go - About 35 mins to fix

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

      func (c *Cluster) Info(ctx context.Context) types.Info {
          info := types.Info{
              NodeAddr: c.GetAdvertiseAddress(),
          }
          c.mu.RLock()
      Severity: Minor
      Found in daemon/cluster/swarm.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 ImageService.PushImage has 5 return statements (exceeds 4 allowed).
      Open

      func (i *ImageService) PushImage(ctx context.Context, sourceRef reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) (retErr error) {
          start := time.Now()
          defer func() {
              if retErr == nil {
                  dimages.ImageActions.WithValues("push").UpdateSince(start)
      Severity: Major
      Found in daemon/containerd/image_push.go - About 35 mins to fix

        Method Cluster.AttachNetwork has 5 return statements (exceeds 4 allowed).
        Open

        func (c *Cluster) AttachNetwork(target string, containerID string, addresses []string) (*network.NetworkingConfig, error) {
            aKey := attacherKey(target, containerID)
            c.mu.Lock()
            state := c.currentNodeState()
            if state.swarmNode == nil || state.swarmNode.Agent() == nil {
        Severity: Major
        Found in daemon/cluster/networks.go - About 35 mins to fix

          Method follow.nextPos has 5 return statements (exceeds 4 allowed).
          Open

          func (fl *follow) nextPos(ctx context.Context, current logPos) (next logPos, ok bool) {
              var st logReadState
              select {
              case <-ctx.Done():
                  return current, false
          Severity: Major
          Found in daemon/logger/loggerutils/follow.go - About 35 mins to fix

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

            func (r *reader) wait(ctx context.Context) (bool, error) {
                deadline := r.drainDeadline
                if d, ok := ctx.Deadline(); ok && d.Before(deadline) {
                    deadline = d
                }
            Severity: Minor
            Found in daemon/logger/journald/read.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 getNode has 5 return statements (exceeds 4 allowed).
            Open

            func getNode(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Node, error) {
                // GetNode to match via full ID.
                if rg, err := c.GetNode(ctx, &swarmapi.GetNodeRequest{NodeID: input}); err == nil {
                    return rg.Node, nil
                }
            Severity: Major
            Found in daemon/cluster/helpers.go - About 35 mins to fix

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

              func getSecret(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Secret, error) {
                  // attempt to lookup secret by full ID
                  if rg, err := c.GetSecret(ctx, &swarmapi.GetSecretRequest{SecretID: input}); err == nil {
                      return rg.Secret, nil
                  }
              Severity: Major
              Found in daemon/cluster/helpers.go - About 35 mins to fix

                Method Copier.copySrc has 5 return statements (exceeds 4 allowed).
                Open

                func (c *Copier) copySrc(name string, src io.Reader) {
                    defer c.copyJobs.Done()
                
                    bufSize := defaultBufSize
                    if sizedLogger, ok := c.dst.(SizedLogger); ok {
                Severity: Major
                Found in daemon/logger/copier.go - About 35 mins to fix

                  Method Cluster.CreateVolume has 5 return statements (exceeds 4 allowed).
                  Open

                  func (c *Cluster) CreateVolume(v volumetypes.CreateOptions) (*volumetypes.Volume, error) {
                      var resp *swarmapi.CreateVolumeResponse
                      if err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
                          volumeSpec := convert.VolumeCreateToGRPC(&v)
                  
                  
                  Severity: Major
                  Found in daemon/cluster/volumes.go - About 35 mins to fix

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

                    func getConfig(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Config, error) {
                        // attempt to lookup config by full ID
                        if rg, err := c.GetConfig(ctx, &swarmapi.GetConfigRequest{ConfigID: input}); err == nil {
                            return rg.Config, nil
                        }
                    Severity: Major
                    Found in daemon/cluster/helpers.go - About 35 mins to fix

                      Method Daemon.ContainerStart has 5 return statements (exceeds 4 allowed).
                      Open

                      func (daemon *Daemon) ContainerStart(ctx context.Context, name string, checkpoint string, checkpointDir string) error {
                          daemonCfg := daemon.config()
                          if checkpoint != "" && !daemonCfg.Experimental {
                              return errdefs.InvalidParameter(errors.New("checkpoint is only supported in experimental mode"))
                          }
                      Severity: Major
                      Found in daemon/start.go - About 35 mins to fix

                        Method Daemon.getActiveContainer has 5 return statements (exceeds 4 allowed).
                        Open

                        func (daemon *Daemon) getActiveContainer(name string) (*container.Container, error) {
                            ctr, err := daemon.GetContainer(name)
                            if err != nil {
                                return nil, err
                            }
                        Severity: Major
                        Found in daemon/exec.go - About 35 mins to fix

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

                          func getNetwork(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Network, error) {
                              // GetNetwork to match via full ID.
                              if rg, err := c.GetNetwork(ctx, &swarmapi.GetNetworkRequest{NetworkID: input}); err == nil {
                                  return rg.Network, nil
                              }
                          Severity: Major
                          Found in daemon/cluster/helpers.go - About 35 mins to fix

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

                            func unlink(name string) error {
                                // Rename the file before deleting it so that the original name is freed
                                // up to be reused, even while there are still open FILE_SHARE_DELETE
                                // file handles. Emulate POSIX unlink() semantics, essentially.
                                name, err := filepath.Abs(name)
                            Severity: Major
                            Found in daemon/logger/loggerutils/file_windows.go - About 35 mins to fix

                              Method Daemon.containerPause has 5 return statements (exceeds 4 allowed).
                              Open

                              func (daemon *Daemon) containerPause(container *container.Container) error {
                                  container.Lock()
                                  defer container.Unlock()
                              
                                  // We cannot Pause the container which is not running
                              Severity: Major
                              Found in daemon/pause.go - About 35 mins to fix

                                Method Daemon.reserveName has 5 return statements (exceeds 4 allowed).
                                Open

                                func (daemon *Daemon) reserveName(id, name string) (string, error) {
                                    if !validContainerNamePattern.MatchString(strings.TrimPrefix(name, "/")) {
                                        return "", errdefs.InvalidParameter(errors.Errorf("Invalid container name (%s), only %s are allowed", name, validContainerNameChars))
                                    }
                                    if name[0] != '/' {
                                Severity: Major
                                Found in daemon/names.go - About 35 mins to fix

                                  Method Cluster.GetUnlockKey has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func (c *Cluster) GetUnlockKey() (string, error) {
                                      var resp *swarmapi.GetUnlockKeyResponse
                                      if err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
                                          client := swarmapi.NewCAClient(state.grpcConn)
                                  
                                  
                                  Severity: Major
                                  Found in daemon/cluster/swarm.go - About 35 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language