dotcloud/docker

View on GitHub

Showing 1,468 of 1,914 total issues

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

    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

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

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

          func Zombie(pid int) (bool, error) {
              if pid < 1 {
                  return false, nil
              }
              data, err := os.ReadFile(fmt.Sprintf("/proc/%d/stat", pid))
          Severity: Major
          Found in pkg/process/process_unix.go - About 35 mins to fix

            Method atomicFileWriter.Close has 5 return statements (exceeds 4 allowed).
            Open

            func (w *atomicFileWriter) Close() (retErr error) {
                defer func() {
                    if retErr != nil || w.writeErr != nil {
                        os.Remove(w.f.Name())
                    }
            Severity: Major
            Found in pkg/ioutils/fswriters.go - About 35 mins to fix

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

              func ValidateMinAPIVersion(ver string) error {
                  if ver == "" {
                      return errors.New(`value is empty`)
                  }
                  if strings.EqualFold(ver[0:1], "v") {
              Severity: Major
              Found in daemon/config/config.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

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

                      func (s *scanner) Scan(ctx context.Context) bool {
                          if s.err != nil {
                              return false
                          }
                      
                      
                      Severity: Major
                      Found in pkg/tailfile/tailfile.go - About 35 mins to fix

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

                        func doUnpack(decompressedArchive io.Reader, relDest, root string, options *archive.TarOptions) error {
                            optionsR, optionsW, err := os.Pipe()
                            if err != nil {
                                return err
                            }
                        Severity: Major
                        Found in pkg/chrootarchive/archive_unix_nolinux.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 || isChunked(r)) && 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 parseSubidFile has 5 return statements (exceeds 4 allowed).
                            Open

                            func parseSubidFile(path, username string) (ranges, error) {
                                var rangeList ranges
                            
                                subidFile, err := os.Open(path)
                                if err != nil {
                            Severity: Major
                            Found in pkg/idtools/idtools.go - About 35 mins to fix

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

                              func doPack(relSrc, root string, options *archive.TarOptions) (io.ReadCloser, error) {
                                  optionsR, optionsW, err := os.Pipe()
                                  if err != nil {
                                      return nil, err
                                  }
                              Severity: Major
                              Found in pkg/chrootarchive/archive_unix_nolinux.go - About 35 mins to fix

                                Method layerStore.initMount has 5 return statements (exceeds 4 allowed).
                                Open

                                func (ls *layerStore) initMount(graphID, parent, mountLabel string, initFunc MountInit, storageOpt map[string]string) (string, error) {
                                    // Use "<graph-id>-init" to maintain compatibility with graph drivers
                                    // which are expecting this layer with this special name. If all
                                    // graph drivers can be updated to not rely on knowing about this layer
                                    // then the initID should be randomly generated.
                                Severity: Major
                                Found in layer/layer_store.go - About 35 mins to fix

                                  Method layerStore.ChecksumForGraphID has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func (ls *layerStore) ChecksumForGraphID(id, parent, newTarDataPath string) (diffID DiffID, size int64, err error) {
                                      rawarchive, err := ls.driver.Diff(id, parent)
                                      if err != nil {
                                          return
                                      }
                                  Severity: Major
                                  Found in layer/migration.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

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

                                      func StickRuntimeDirContents(files []string) ([]string, error) {
                                          runtimeDir, err := GetRuntimeDir()
                                          if err != nil {
                                              // ignore error if runtimeDir is empty
                                              return nil, nil
                                      Severity: Major
                                      Found in pkg/homedir/homedir_linux.go - About 35 mins to fix

                                        Function Join has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                                        Open

                                        func Join(ctx context.Context, path, subpath string) (*SafePath, error) {
                                            base, subpart, err := evaluatePath(path, subpath)
                                            if err != nil {
                                                return nil, err
                                            }
                                        Severity: Minor
                                        Found in internal/safepath/join_windows.go - About 25 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

                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language