dotcloud/docker

View on GitHub

Showing 1,468 of 1,914 total issues

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

func (b *Builder) exportImage(ctx context.Context, state *dispatchState, layer builder.RWLayer, parent builder.Image, runConfig *container.Config) error {
    newLayer, err := layer.Commit()
    if err != nil {
        return err
    }
Severity: Major
Found in builder/dockerfile/internals.go - About 35 mins to fix

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

    func FromArchive(tarStream io.Reader) (builder.Source, error) {
        root, err := longpath.MkdirTemp("", "docker-builder")
        if err != nil {
            return nil, err
        }
    Severity: Major
    Found in builder/remotecontext/archive.go - About 35 mins to fix

      Method localImporter.importInlineCache has 5 return statements (exceeds 4 allowed).
      Open

      func (li *localImporter) importInlineCache(ctx context.Context, dt []byte, cc solver.CacheExporterTarget) error {
          var img image
      
          if err := json.Unmarshal(dt, &img); err != nil {
              return err
      Severity: Major
      Found in builder/builder-next/adapters/localinlinecache/inlinecache.go - About 35 mins to fix

        Method imageRouter.getImagesSearch has 5 return statements (exceeds 4 allowed).
        Open

        func (ir *imageRouter) getImagesSearch(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/image/image_routes.go - About 35 mins to fix

          Method ViewDB.GetByPrefix has 5 return statements (exceeds 4 allowed).
          Open

          func (db *ViewDB) GetByPrefix(s string) (string, error) {
              if s == "" {
                  return "", errdefs.InvalidParameter(errors.New("prefix can't be empty"))
              }
              iter, err := db.store.Txn(false).Get(memdbContainersTable, memdbIDIndexPrefix, s)
          Severity: Major
          Found in container/view.go - About 35 mins to fix

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

            func lookupNTAccount(ctx context.Context, builder *Builder, accountName string, state *dispatchState) (idtools.Identity, error) {
                source, _ := filepath.Split(os.Args[0])
            
                target := "C:\\Docker"
                targetExecutable := target + "\\containerutility.exe"
            Severity: Major
            Found in builder/dockerfile/internals_windows.go - About 35 mins to fix

              Method networkRouter.deleteNetwork has 5 return statements (exceeds 4 allowed).
              Open

              func (n *networkRouter) deleteNetwork(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/network/network_routes.go - About 35 mins to fix

                Method volumeRouter.putVolumesUpdate has 5 return statements (exceeds 4 allowed).
                Open

                func (v *volumeRouter) putVolumesUpdate(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
                    if !v.cluster.IsManager() {
                        return errdefs.Unavailable(errors.New("volume update only valid for cluster volumes, but swarm is unavailable"))
                    }
                
                
                Severity: Major
                Found in api/server/router/volume/volume_routes.go - About 35 mins to fix

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

                  func dispatchTriggeredOnBuild(ctx context.Context, d dispatchRequest, triggers []string) error {
                      fmt.Fprintf(d.builder.Stdout, "# Executing %d build trigger", len(triggers))
                      if len(triggers) > 1 {
                          fmt.Fprint(d.builder.Stdout, "s")
                      }
                  Severity: Major
                  Found in builder/dockerfile/dispatchers.go - About 35 mins to fix

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

                    func ValidateMirror(val string) (string, error) {
                        uri, err := url.Parse(val)
                        if err != nil {
                            return "", invalidParamWrapf(err, "invalid mirror: %q is not a valid URI", val)
                        }
                    Severity: Major
                    Found in registry/config.go - About 35 mins to fix

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

                      func toBuildkitExtraHosts(inp []string, hostGatewayIP net.IP) (string, error) {
                          if len(inp) == 0 {
                              return "", nil
                          }
                          hosts := make([]string, 0, len(inp))
                      Severity: Major
                      Found in builder/builder-next/builder.go - About 35 mins to fix

                        Method networkRouter.getNetworksList has 5 return statements (exceeds 4 allowed).
                        Open

                        func (n *networkRouter) getNetworksList(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/network/network_routes.go - About 35 mins to fix

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

                          func getAccountIdentity(ctx context.Context, builder *Builder, accountName string, ctrRootPath string, state *dispatchState) (idtools.Identity, error) {
                              // If this is potentially a string SID then attempt to convert it to verify
                              // this, otherwise continue looking for the account.
                              if strings.HasPrefix(accountName, "S-") || strings.HasPrefix(accountName, "s-") {
                                  sid, err := windows.StringToSid(accountName)
                          Severity: Major
                          Found in builder/dockerfile/internals_windows.go - About 35 mins to fix

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

                            func DebugRequestMiddleware(handler func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error) func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
                                return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) (retErr error) {
                                    logger := log.G(ctx)
                            
                                    // Use a variable for fields to prevent overhead of repeatedly
                            Severity: Minor
                            Found in api/server/middleware/debug.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 swarmRouter.swarmLogs has 5 return statements (exceeds 4 allowed).
                            Open

                            func (sr *swarmRouter) swarmLogs(ctx context.Context, w http.ResponseWriter, r *http.Request, selector *backend.LogSelector) error {
                                // Args are validated before the stream starts because when it starts we're
                                // sending HTTP 200 by writing an empty chunk of data to tell the client that
                                // daemon is going to stream. By sending this initial HTTP 200 we can't report
                                // any error after the stream starts (i.e. container not found, wrong parameters)
                            Severity: Major
                            Found in api/server/router/swarm/helpers.go - About 35 mins to fix

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

                              func (sr *swarmRouter) getServices(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/swarm/cluster_routes.go - About 35 mins to fix

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

                                func (config *serviceConfig) loadInsecureRegistries(registries []string) error {
                                    // Localhost is by default considered as an insecure registry. This is a
                                    // stop-gap for people who are running a private registry on localhost.
                                    registries = append(registries, "::1/128", "127.0.0.0/8")
                                
                                
                                Severity: Minor
                                Found in registry/config.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 dispatchWorkdir has 5 return statements (exceeds 4 allowed).
                                Open

                                func dispatchWorkdir(ctx context.Context, d dispatchRequest, c *instructions.WorkdirCommand) error {
                                    runConfig := d.state.runConfig
                                    var err error
                                    runConfig.WorkingDir, err = normalizeWorkdir(d.state.operatingSystem, runConfig.WorkingDir, c.Path)
                                    if err != nil {
                                Severity: Major
                                Found in builder/dockerfile/dispatchers.go - About 35 mins to fix

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

                                  func fixPermissionsWindows(source, destination, SID string) error {
                                      privileges := []string{winio.SeRestorePrivilege, idtools.SeTakeOwnershipPrivilege}
                                  
                                      err := winio.EnableProcessPrivileges(privileges)
                                      if err != nil {
                                  Severity: Major
                                  Found in builder/dockerfile/copy_windows.go - About 35 mins to fix

                                    Method gitRepo.checkout has 5 return statements (exceeds 4 allowed).
                                    Open

                                    func (repo gitRepo) checkout(root string) (string, error) {
                                        // Try checking out by ref name first. This will work on branches and sets
                                        // .git/HEAD to the current branch name
                                        if output, err := repo.gitWithinDir(root, "checkout", repo.ref); err != nil {
                                            // If checking out by branch name fails check out the last fetched ref
                                    Severity: Major
                                    Found in builder/remotecontext/git/gitutils.go - About 35 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language