dotcloud/docker

View on GitHub

Showing 1,885 of 1,885 total issues

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

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

      func (r *reader) drainJournal() (bool, error) {
          for i := 0; ; i++ {
              // Read the entry's timestamp.
              timestamp, err := r.j.Realtime()
              if err != nil {
      Severity: Major
      Found in daemon/logger/journald/read.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

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

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

            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

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

              func (daemon *Daemon) containerArchivePath(container *container.Container, path string) (content io.ReadCloser, stat *containertypes.PathStat, err error) {
                  container.Lock()
              
                  defer func() {
                      if err != nil {
              Severity: Major
              Found in daemon/archive_unix.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

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

                    func (daemon *Daemon) containerStatPath(container *container.Container, path string) (stat *containertypes.PathStat, 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.populateInitCommit has 5 return statements (exceeds 4 allowed).
                      Open

                      func (daemon *Daemon) populateInitCommit(ctx context.Context, v *system.Info, cfg *configStore) error {
                          v.InitBinary = cfg.GetInitPath()
                          initBinary, err := cfg.LookupInitPath()
                          if err != nil {
                              log.G(ctx).WithError(err).Warnf("Failed to find docker-init")
                      Severity: Major
                      Found in daemon/info_unix.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 Reload has 5 return statements (exceeds 4 allowed).
                        Open

                        func Reload(configFile string, flags *pflag.FlagSet, reload func(*Config)) error {
                            log.G(context.TODO()).Infof("Got signal to reload configuration, reloading from: %s", configFile)
                            newConfig, err := getConflictFreeConfiguration(configFile, flags)
                            if err != nil {
                                if flags.Changed("config-file") || !os.IsNotExist(err) {
                        Severity: Major
                        Found in daemon/config/config.go - About 35 mins to fix

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

                          func Init(proto, addr, socketGroup string, tlsConfig *tls.Config) ([]net.Listener, error) {
                              ls := []net.Listener{}
                          
                              switch proto {
                              case "fd":
                          Severity: Major
                          Found in daemon/listeners/listeners_linux.go - About 35 mins to fix

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

                            func (daemon *Daemon) updateNetwork(cfg *config.Config, ctr *container.Container) error {
                                var (
                                    start = time.Now()
                                    ctrl  = daemon.netController
                                    sid   = ctr.NetworkSettings.SandboxID
                            Severity: Major
                            Found in daemon/container_operations.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

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

                                func (daemon *Daemon) releaseNetwork(ctx context.Context, ctr *container.Container) {
                                    ctx = context.WithoutCancel(ctx)
                                
                                    start := time.Now()
                                    // If live-restore is enabled, the daemon cleans up dead containers when it starts up. In that case, the
                                Severity: Major
                                Found in daemon/container_operations.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

                                    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 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
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language