docker/docker

View on GitHub

Showing 1,412 of 1,855 total issues

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.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 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

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

        func validateContainerConfig(config *containertypes.Config) error {
            if config == nil {
                return nil
            }
            if err := translateWorkingDir(config); err != nil {
        Severity: Major
        Found in daemon/container.go - About 35 mins to fix

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

          func (daemon *Daemon) ContainerKill(name, stopSignal string) error {
              var (
                  err error
                  sig = syscall.SIGKILL
              )
          Severity: Major
          Found in daemon/kill.go - About 35 mins to fix

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

            func buildEndpointInfo(networkSettings *internalnetwork.Settings, n *libnetwork.Network, ep *libnetwork.Endpoint) error {
                if ep == nil {
                    return errors.New("endpoint cannot be nil")
                }
            
            
            Severity: Major
            Found in daemon/network.go - About 35 mins to fix

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

              func New(info logger.Info) (logger.Logger, error) {
                  initGCP()
              
                  var project string
                  if projectID != "" {
              Severity: Major
              Found in daemon/logger/gcplogs/gcplogging.go - About 35 mins to fix

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

                func copyRegular(srcPath, dstPath string, fileinfo os.FileInfo, copyWithFileRange, copyWithFileClone *bool) error {
                    srcFile, err := os.Open(srcPath)
                    if err != nil {
                        return err
                    }
                Severity: Major
                Found in daemon/graphdriver/copy/copy.go - About 35 mins to fix

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

                  func updateJoinInfo(networkSettings *network.Settings, n *libnetwork.Network, ep *libnetwork.Endpoint) error {
                      if ep == nil {
                          return errors.New("invalid enppoint whhile building portmap info")
                      }
                  
                  
                  Severity: Major
                  Found in daemon/container_operations.go - About 35 mins to fix

                    Function validateEndpointSettings has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func validateEndpointSettings(nw *libnetwork.Network, nwName string, epConfig *networktypes.EndpointSettings) error {
                        if epConfig == nil {
                            return nil
                        }
                    
                    
                    Severity: Minor
                    Found in daemon/container_operations.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 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/prune.go - About 35 mins to fix

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

                      func (daemon *Daemon) releaseNetwork(container *container.Container) {
                          start := time.Now()
                          // If live-restore is enabled, the daemon cleans up dead containers when it starts up. In that case, the
                          // netController hasn't been initialized yet and so we can't proceed.
                          // TODO(aker): If we hit this case, the endpoint state won't be cleaned up (ie. no call to cleanOperationalData).
                      Severity: Major
                      Found in daemon/container_operations.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.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
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language