docker/docker

View on GitHub

Showing 1,855 of 1,855 total issues

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 Daemon.deleteNetwork has 5 return statements (exceeds 4 allowed).
    Open

    func (daemon *Daemon) deleteNetwork(nw *libnetwork.Network, dynamic bool) error {
        if runconfig.IsPreDefinedNetwork(nw.Name()) && !dynamic {
            err := fmt.Errorf("%s is a pre-defined network and cannot be removed", nw.Name())
            return errdefs.Forbidden(err)
        }
    Severity: Major
    Found in daemon/network.go - About 35 mins to fix

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

      func getSystemCPUUsage() (cpuUsage uint64, cpuNum uint32, err error) {
          f, err := os.Open("/proc/stat")
          if err != nil {
              return 0, 0, err
          }
      Severity: Major
      Found in daemon/stats_unix.go - About 35 mins to fix

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

        func (daemon *Daemon) createSpecWindowsFields(c *container.Container, s *specs.Spec, isHyperV bool) error {
            s.Hostname = c.FullHostname()
        
            if len(s.Process.Cwd) == 0 {
                // We default to C:\ to workaround the oddity of the case that the
        Severity: Major
        Found in daemon/oci_windows.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 New has 5 return statements (exceeds 4 allowed).
            Open

            func New(info logger.Info) (logger.Logger, error) {
                fluentConfig, err := parseConfig(info.Config)
                if err != nil {
                    return nil, errdefs.InvalidParameter(err)
                }
            Severity: Major
            Found in daemon/logger/fluentd/fluentd.go - About 35 mins to fix

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

              func (daemon *Daemon) containerRm(cfg *config.Config, name string, opts *backend.ContainerRmConfig) error {
                  start := time.Now()
                  ctr, err := daemon.GetContainer(name)
                  if err != nil {
                      return err
              Severity: Major
              Found in daemon/delete.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.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
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language