dotcloud/docker

View on GitHub

Showing 1,468 of 1,914 total issues

Method buildRouter.postPrune has 5 return statements (exceeds 4 allowed).
Open

func (br *buildRouter) postPrune(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
    if err := httputils.ParseForm(r); err != nil {
        return err
    }
    fltrs, err := filters.FromJSON(r.Form.Get("filters"))
Severity: Major
Found in api/server/router/build/build_routes.go - About 35 mins to fix

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

    func lookupGroup(groupStr, filepath string) (int, error) {
        // if the string is actually a gid integer, parse to int and return
        // as we don't need to translate with the help of files
        gid, err := strconv.Atoi(groupStr)
        if err == nil {
    Severity: Major
    Found in builder/dockerfile/internals_linux.go - About 35 mins to fix

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

      func resolveCmdLine(cmd instructions.ShellDependantCmdLine, runConfig *container.Config, os, command, original string) ([]string, bool) {
          // Make sure we return an empty array if there is no cmd.CmdLine
          if len(cmd.CmdLine) == 0 {
              return []string{}, runConfig.ArgsEscaped
          }
      Severity: Major
      Found in builder/dockerfile/dispatchers_windows.go - About 35 mins to fix

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

        func GetWithStatusError(address string) (resp *http.Response, err error) {
            resp, err = http.Get(address) // #nosec G107 -- ignore G107: Potential HTTP request made with variable url
            if err != nil {
                if uerr, ok := err.(*url.Error); ok {
                    if derr, ok := uerr.Err.(*net.DNSError); ok && !derr.IsTimeout {
        Severity: Major
        Found in builder/remotecontext/remote.go - About 35 mins to fix

          Method swarmRouter.updateService has 5 return statements (exceeds 4 allowed).
          Open

          func (sr *swarmRouter) updateService(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
              var service types.ServiceSpec
              if err := httputils.ReadJSON(r, &service); err != nil {
                  return err
              }
          Severity: Major
          Found in api/server/router/swarm/cluster_routes.go - About 35 mins to fix

            Method v1Endpoint.ping has 5 return statements (exceeds 4 allowed).
            Open

            func (e *v1Endpoint) ping() (v1PingResult, error) {
                if e.String() == IndexServer {
                    // Skip the check, we know this one is valid
                    // (and we never want to fallback to http in case of error)
                    return v1PingResult{}, nil
            Severity: Major
            Found in registry/search_endpoint_v1.go - About 35 mins to fix

              Method containerRouter.postContainerExecCreate has 5 return statements (exceeds 4 allowed).
              Open

              func (c *containerRouter) postContainerExecCreate(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
                  if err := httputils.ParseForm(r); err != nil {
                      return err
                  }
              
              
              Severity: Major
              Found in api/server/router/container/exec.go - About 35 mins to fix

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

                func lookupUser(userStr, filepath string) (int, error) {
                    // if the string is actually a uid integer, parse to int and return
                    // as we don't need to translate with the help of files
                    uid, err := strconv.Atoi(userStr)
                    if err == nil {
                Severity: Major
                Found in builder/dockerfile/internals_linux.go - About 35 mins to fix

                  Method Builder.build has 5 return statements (exceeds 4 allowed).
                  Open

                  func (b *Builder) build(ctx context.Context, source builder.Source, dockerfile *parser.Result) (*builder.Result, error) {
                      defer b.imageSources.Unmount()
                  
                      stages, metaArgs, err := instructions.Parse(dockerfile.AST, nil)
                      if err != nil {
                  Severity: Major
                  Found in builder/dockerfile/builder.go - About 35 mins to fix

                    Method grpcRouter.serveGRPC has 5 return statements (exceeds 4 allowed).
                    Open

                    func (gr *grpcRouter) serveGRPC(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
                        h, ok := w.(http.Hijacker)
                        if !ok {
                            return errors.New("handler does not support hijack")
                        }
                    Severity: Major
                    Found in api/server/router/grpc/grpc_routes.go - About 35 mins to fix

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

                      func (ctr *container) NewTask(_ context.Context, _ string, withStdin bool, attachStdio libcontainerdtypes.StdioCallback) (_ libcontainerdtypes.Task, retErr error) {
                          ctr.mu.Lock()
                          defer ctr.mu.Unlock()
                      
                          switch {
                      Severity: Minor
                      Found in libcontainerd/local/local_windows.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.getBestPresentImageManifest has 5 return statements (exceeds 4 allowed).
                      Open

                      func (i *ImageService) getBestPresentImageManifest(ctx context.Context, img containerdimages.Image, pm platforms.MatchComparer) (*ImageManifest, error) {
                          var best *ImageManifest
                          var bestPlatform ocispec.Platform
                      
                          err := i.walkImageManifests(ctx, img, func(im *ImageManifest) error {
                      Severity: Major
                      Found in daemon/containerd/image.go - About 35 mins to fix

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

                        func (c *container) NewTask(ctx context.Context, checkpointDir string, withStdin bool, attachStdio libcontainerdtypes.StdioCallback) (libcontainerdtypes.Task, error) {
                            var (
                                checkpoint     *types.Descriptor
                                t              containerd.Task
                                rio            cio.IO
                        Severity: Minor
                        Found in libcontainerd/remote/client.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.PushImage has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func (i *ImageService) PushImage(ctx context.Context, sourceRef reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) (retErr error) {
                            start := time.Now()
                            defer func() {
                                if retErr == nil {
                                    dimages.ImageActions.WithValues("push").UpdateSince(start)
                        Severity: Minor
                        Found in daemon/containerd/image_push.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 GetTimestamp has 5 return statements (exceeds 4 allowed).
                        Open

                        func GetTimestamp(value string, reference time.Time) (string, error) {
                            if d, err := time.ParseDuration(value); value != "0" && err == nil {
                                return strconv.FormatInt(reference.Add(-d).Unix(), 10), nil
                            }
                        
                        
                        Severity: Major
                        Found in api/types/time/timestamp.go - About 35 mins to fix

                          Method task.Resume has 5 return statements (exceeds 4 allowed).
                          Open

                          func (t *task) Resume(ctx context.Context) error {
                              if t.ctr.ociSpec.Windows.HyperV == nil {
                                  return errors.New("cannot resume Windows Server Containers")
                              }
                          
                          
                          Severity: Major
                          Found in libcontainerd/local/local_windows.go - About 35 mins to fix

                            Method Args.MatchKVList has 5 return statements (exceeds 4 allowed).
                            Open

                            func (args Args) MatchKVList(key string, sources map[string]string) bool {
                                fieldValues := args.fields[key]
                            
                                // do not filter if there is no filter set or cannot determine filter
                                if len(fieldValues) == 0 {
                            Severity: Major
                            Found in api/types/filters/parse.go - About 35 mins to fix

                              Method container.createIO has 5 return statements (exceeds 4 allowed).
                              Open

                              func (c *container) createIO(fifos *cio.FIFOSet, stdinCloseSync chan containerd.Process, attachStdio libcontainerdtypes.StdioCallback) (cio.IO, error) {
                                  var (
                                      io  *cio.DirectIO
                                      err error
                                  )
                              Severity: Major
                              Found in libcontainerd/remote/client.go - About 35 mins to fix

                                Method containerRouter.getContainersJSON has 5 return statements (exceeds 4 allowed).
                                Open

                                func (c *containerRouter) getContainersJSON(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
                                    if err := httputils.ParseForm(r); err != nil {
                                        return err
                                    }
                                    filter, err := filters.FromJSON(r.Form.Get("filters"))
                                Severity: Major
                                Found in api/server/router/container/container_routes.go - About 35 mins to fix

                                  Method task.Exec has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func (t *task) Exec(ctx context.Context, processID string, spec *specs.Process, withStdin bool, attachStdio libcontainerdtypes.StdioCallback) (_ libcontainerdtypes.Process, retErr error) {
                                      hcsContainer, err := t.getHCSContainer()
                                      if err != nil {
                                          return nil, err
                                      }
                                  Severity: Major
                                  Found in libcontainerd/local/local_windows.go - About 35 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language