dotcloud/docker

View on GitHub

Showing 1,904 of 1,904 total issues

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

func (ir *imageRouter) postImagesPush(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
    metaHeaders := map[string][]string{}
    for k, v := range r.Header {
        if strings.HasPrefix(k, "X-Meta-") {
            metaHeaders[k] = v
Severity: Minor
Found in api/server/router/image/image_routes.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

Method containerRouter.postContainerExecStart has 7 return statements (exceeds 4 allowed).
Open

func (s *containerRouter) postContainerExecStart(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
    if err := httputils.ParseForm(r); err != nil {
        return err
    }

Severity: Major
Found in api/server/router/container/exec.go - About 45 mins to fix

    Method Daemon.cleanupMounts has 7 return statements (exceeds 4 allowed).
    Open

    func (daemon *Daemon) cleanupMounts(cfg *config.Config) error {
        if err := daemon.cleanupMountsByID(""); err != nil {
            return err
        }
    
    
    Severity: Major
    Found in daemon/daemon_linux.go - About 45 mins to fix

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

      func (c cacheAdaptor) Get(id image.ID) (*image.Image, error) {
          ctx := context.TODO()
          ref := id.String()
      
          outImg, err := c.is.GetImage(ctx, id.String(), backend.GetImageOpts{})
      Severity: Minor
      Found in daemon/containerd/cache.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

      Method Daemon.createContainerOSSpecificSettings has 7 return statements (exceeds 4 allowed).
      Open

      func (daemon *Daemon) createContainerOSSpecificSettings(ctx context.Context, container *container.Container, config *containertypes.Config, hostConfig *containertypes.HostConfig) error {
          if err := daemon.Mount(container); err != nil {
              return err
          }
          defer daemon.Unmount(container)
      Severity: Major
      Found in daemon/create_unix.go - About 45 mins to fix

        Method ImageService.PushImage has 6 arguments (exceeds 4 allowed). Consider refactoring.
        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) {
        Severity: Minor
        Found in daemon/containerd/image_push.go - About 45 mins to fix

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

          func findMissingMountable(ctx context.Context, store content.Store, queue *jobs,
              target ocispec.Descriptor, targetRef reference.Named, limiter *semaphore.Weighted,
          Severity: Minor
          Found in daemon/containerd/image_push.go - About 45 mins to fix

            Method client.NewContainer has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            func (c *client) NewContainer(ctx context.Context, id string, ociSpec *specs.Spec, shim string, runtimeOptions interface{}, opts ...containerd.NewContainerOpts) (libcontainerdtypes.Container, error) {
            Severity: Minor
            Found in libcontainerd/remote/client.go - About 45 mins to fix

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

              func saveArchive(ctx context.Context, cs content.Store, layerReader io.Reader) (digest.Digest, digest.Digest, string, error) {
                  // Wrap the reader in buffered reader to allow peeks.
                  p := pools.BufioReader32KPool
                  bufRd := p.Get(layerReader)
                  defer p.Put(bufRd)
              Severity: Major
              Found in daemon/containerd/image_import.go - About 45 mins to fix

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

                func findMissingMountable(ctx context.Context, store content.Store, queue *jobs,
                    target ocispec.Descriptor, targetRef reference.Named, limiter *semaphore.Weighted,
                ) (map[digest.Digest]distributionSource, error) {
                    mountableBlobs := map[digest.Digest]distributionSource{}
                    var mutex sync.Mutex
                Severity: Major
                Found in daemon/containerd/image_push.go - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if c.waitServe(ctx) {
                                          go c.processEventStream(ctx, ns)
                                          return
                                      }
                  Severity: Major
                  Found in libcontainerd/remote/client.go - About 45 mins to fix

                    Method task.CreateCheckpoint has 7 return statements (exceeds 4 allowed).
                    Open

                    func (t *task) CreateCheckpoint(ctx context.Context, checkpointDir string, exit bool) error {
                        img, err := t.Task.Checkpoint(ctx, t.ctr.getCheckpointOptions(exit))
                        if err != nil {
                            return wrapError(err)
                        }
                    Severity: Major
                    Found in libcontainerd/remote/client.go - About 45 mins to fix

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

                      func ifaceAddrs(linkName string) (v4, v6 []*net.IPNet, err error) {
                          nl := ns.NlHandle()
                          link, err := nl.LinkByName(linkName)
                          if err != nil {
                              if !errors.As(err, new(netlink.LinkNotFoundError)) {
                      Severity: Major
                      Found in daemon/daemon_linux.go - About 45 mins to fix

                        Method ImageService.ImportImage has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        func (i *ImageService) ImportImage(ctx context.Context, ref reference.Named, platform *ocispec.Platform, msg string, layerReader io.Reader, changes []string) (image.ID, error) {
                        Severity: Minor
                        Found in daemon/containerd/image_import.go - About 45 mins to fix

                          Method ImageService.applyDiffLayer has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          func (i *ImageService) applyDiffLayer(ctx context.Context, name string, containerID string, sn snapshots.Snapshotter, differ diff.Applier, diffDesc ocispec.Descriptor) (retErr error) {
                          Severity: Minor
                          Found in daemon/containerd/image_commit.go - About 45 mins to fix

                            Method client.newStdioPipes has 7 return statements (exceeds 4 allowed).
                            Open

                            func (c *client) newStdioPipes(fifos *cio.FIFOSet) (_ *stdioPipes, err error) {
                                p := &stdioPipes{}
                                if fifos.Stdin != "" {
                                    c.logger.WithField("stdin", fifos.Stdin).Debug("listen")
                                    l, err := winio.ListenPipe(fifos.Stdin, nil)
                            Severity: Major
                            Found in libcontainerd/remote/client_io_windows.go - About 45 mins to fix

                              Method Daemon.populateVolume has 7 return statements (exceeds 4 allowed).
                              Open

                              func (daemon *Daemon) populateVolume(ctx context.Context, c *container.Container, mnt *volumemounts.MountPoint) error {
                                  ctrDestPath, err := c.GetResourcePath(mnt.Destination)
                                  if err != nil {
                                      return err
                                  }
                              Severity: Major
                              Found in daemon/create_unix.go - About 45 mins to fix

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

                                func setExitCodeFromError(setExitCode func(exitStatus), err error) error {
                                    if err == nil {
                                        return nil
                                    }
                                    errDesc := status.Convert(err).Message()
                                Severity: Major
                                Found in daemon/errors.go - About 45 mins to fix

                                  Method ImageService.pushRef has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                  func (i *ImageService) pushRef(ctx context.Context, targetRef reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, out progress.Output) (retErr error) {
                                  Severity: Minor
                                  Found in daemon/containerd/image_push.go - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                            if err := unmount(mnt); err != nil {
                                                                log.G(context.TODO()).Error(err)
                                                                errs = append(errs, err.Error())
                                                            }
                                    Severity: Major
                                    Found in daemon/daemon_linux.go - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language