docker/docker

View on GitHub

Showing 1,855 of 1,855 total issues

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

func (daemon *Daemon) getNetworkedContainer(containerID, connectedContainerID string) (*container.Container, error) {
    nc, err := daemon.GetContainer(connectedContainerID)
    if err != nil {
        return nil, err
    }
Severity: Major
Found in daemon/container_operations.go - About 35 mins to fix

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

    func (daemon *Daemon) killWithSignal(container *containerpkg.Container, stopSignal syscall.Signal) error {
        log.G(context.TODO()).Debugf("Sending kill signal %d to container %s", stopSignal, container.ID)
        container.Lock()
        defer container.Unlock()
    
    
    Severity: Major
    Found in daemon/kill.go - About 35 mins to fix

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

      func (daemon *Daemon) updateNetworkSettings(container *container.Container, n *libnetwork.Network, endpointConfig *networktypes.EndpointSettings) error {
          if container.NetworkSettings == nil {
              container.NetworkSettings = &network.Settings{}
          }
          if container.NetworkSettings.Networks == nil {
      Severity: Major
      Found in daemon/container_operations.go - About 35 mins to fix

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

        func (daemon *Daemon) registerName(container *container.Container) error {
            if daemon.Exists(container.ID) {
                return fmt.Errorf("Container is already loaded")
            }
            if err := validateID(container.ID); err != nil {
        Severity: Major
        Found in daemon/names.go - About 35 mins to fix

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

          func (daemon *Daemon) updateNetwork(cfg *config.Config, container *container.Container) error {
              var (
                  start = time.Now()
                  ctrl  = daemon.netController
                  sid   = container.NetworkSettings.SandboxID
          Severity: Major
          Found in daemon/container_operations.go - About 35 mins to fix

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

            func getUserFromContainerd(ctx context.Context, containerdCli *containerd.Client, ec *container.ExecConfig) (specs.User, error) {
                ctr, err := containerdCli.LoadContainer(ctx, ec.Container.ID)
                if err != nil {
                    return specs.User{}, err
                }
            Severity: Major
            Found in daemon/exec_linux.go - About 35 mins to fix

              Method ImageService.GetLayerFolders has 5 return statements (exceeds 4 allowed).
              Open

              func (i *ImageService) GetLayerFolders(img *image.Image, rwLayer layer.RWLayer, containerID string) ([]string, error) {
                  folders := []string{}
                  rd := len(img.RootFS.DiffIDs)
                  for index := 1; index <= rd; index++ {
                      // FIXME: why does this mutate the RootFS?
              Severity: Major
              Found in daemon/images/image_windows.go - About 35 mins to fix

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

                func getUntilFromPruneFilters(pruneFilters filters.Args) (time.Time, error) {
                    until := time.Time{}
                    if !pruneFilters.Contains("until") {
                        return until, nil
                    }
                Severity: Major
                Found in daemon/images/image_prune.go - About 35 mins to fix

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

                  func (daemon *Daemon) containerStatPath(container *container.Container, path string) (stat *types.ContainerPathStat, err error) {
                      container.Lock()
                      defer container.Unlock()
                  
                      // Make sure an online file-system operation is permitted.
                  Severity: Major
                  Found in daemon/archive_windows.go - About 35 mins to fix

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

                    func (daemon *Daemon) containerArchivePath(container *container.Container, path string) (content io.ReadCloser, stat *types.ContainerPathStat, err error) {
                        container.Lock()
                    
                        defer func() {
                            if err != nil {
                    Severity: Major
                    Found in daemon/archive_unix.go - About 35 mins to fix

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

                      func RebaseArchiveEntries(srcContent io.Reader, oldBase, newBase string) io.ReadCloser {
                          if oldBase == string(os.PathSeparator) {
                              // If oldBase specifies the root directory, use an empty string as
                              // oldBase instead so that newBase doesn't replace the path separator
                              // that all paths will start with.
                      Severity: Major
                      Found in pkg/archive/copy.go - About 35 mins to fix

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

                        func (i *ImageService) ImageHistory(ctx context.Context, name string) ([]*image.HistoryResponseItem, error) {
                            start := time.Now()
                            img, err := i.GetImage(ctx, name, backend.GetImageOpts{})
                            if err != nil {
                                return nil, err
                        Severity: Minor
                        Found in daemon/images/image_history.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.manifestMatchesPlatform has 5 return statements (exceeds 4 allowed).
                        Open

                        func (i *ImageService) manifestMatchesPlatform(ctx context.Context, img *image.Image, platform ocispec.Platform) (bool, error) {
                            ls, err := i.leases.ListResources(ctx, leases.Lease{ID: imageKey(img.ID().String())})
                            if err != nil {
                                if cerrdefs.IsNotFound(err) {
                                    return false, nil
                        Severity: Major
                        Found in daemon/images/image.go - About 35 mins to fix

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

                          func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error) {
                              if refOrID == "" { // FROM scratch
                                  if runtime.GOOS == "windows" {
                                      return nil, nil, fmt.Errorf(`"FROM scratch" is not supported on Windows`)
                                  }
                          Severity: Minor
                          Found in daemon/images/image_builder.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 populateInitVersion has 5 return statements (exceeds 4 allowed).
                          Open

                          func populateInitVersion(ctx context.Context, cfg *configStore, v *types.Version) error {
                              initBinary, err := cfg.LookupInitPath()
                              if err != nil {
                                  log.G(ctx).WithError(err).Warn("Failed to find docker-init")
                                  return nil
                          Severity: Major
                          Found in daemon/info_unix.go - About 35 mins to fix

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

                            func parseDefaultRuntimeVersion(rts *runtimes) (runtime, version, commit string, err error) {
                                shim, opts, err := rts.Get(rts.Default)
                                if err != nil {
                                    return "", "", "", err
                                }
                            Severity: Major
                            Found in daemon/info_unix.go - About 35 mins to fix

                              Method cdiHandler.injectCDIDevices has 5 return statements (exceeds 4 allowed).
                              Open

                              func (c *cdiHandler) injectCDIDevices(s *specs.Spec, dev *deviceInstance) error {
                                  if dev.req.Count != 0 {
                                      return errdefs.InvalidParameter(errors.New("unexpected count in CDI device request"))
                                  }
                                  if len(dev.req.Options) > 0 {
                              Severity: Major
                              Found in daemon/cdi.go - About 35 mins to fix

                                Method Ctx.AuthZRequest has 5 return statements (exceeds 4 allowed).
                                Open

                                func (ctx *Ctx) AuthZRequest(w http.ResponseWriter, r *http.Request) error {
                                    var body []byte
                                    if sendBody(ctx.requestURI, r.Header) && r.ContentLength > 0 && r.ContentLength < maxBodySize {
                                        var err error
                                        body, r.Body, err = drainBody(r.Body)
                                Severity: Major
                                Found in pkg/authorization/authz.go - About 35 mins to fix

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

                                  func GetTotalUsedFds(ctx context.Context) int {
                                      ctx, span := tracing.StartSpan(ctx, "GetTotalUsedFds")
                                      defer span.End()
                                  
                                      name := fmt.Sprintf("/proc/%d/fd", os.Getpid())
                                  Severity: Major
                                  Found in pkg/fileutils/fileutils_linux.go - About 35 mins to fix

                                    Method ImageService.GetImage has 5 return statements (exceeds 4 allowed).
                                    Open

                                    func (i *ImageService) GetImage(ctx context.Context, refOrID string, options backend.GetImageOpts) (*image.Image, error) {
                                        img, err := i.getImage(ctx, refOrID, options)
                                        if err != nil {
                                            return nil, err
                                        }
                                    Severity: Major
                                    Found in daemon/images/image.go - About 35 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language