dotcloud/docker

View on GitHub

Showing 1,468 of 1,914 total issues

Method Daemon.handleContainerExit has 96 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (daemon *Daemon) handleContainerExit(c *container.Container, e *libcontainerdtypes.EventInfo) error {
    var exitStatus container.ExitStatus
    c.Lock()

    cfg := daemon.config()
Severity: Major
Found in daemon/monitor.go - About 2 hrs to fix

    Method Daemon.connectToNetwork has 96 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (daemon *Daemon) connectToNetwork(ctx context.Context, cfg *config.Config, ctr *container.Container, idOrName string, endpointConfig *network.EndpointSettings, updateSettings bool) (retErr error) {
        containerName := strings.TrimPrefix(ctr.Name, "/")
        ctx, span := otel.Tracer("").Start(ctx, "daemon.connectToNetwork", trace.WithAttributes(
            attribute.String("container.ID", ctr.ID),
            attribute.String("container.name", containerName),
    Severity: Major
    Found in daemon/container_operations.go - About 2 hrs to fix

      driver has 25 methods (exceeds 20 allowed). Consider refactoring.
      Open

      type driver struct {
          config            configuration
          natChain          *iptables.ChainInfo
          filterChain       *iptables.ChainInfo
          isolationChain1   *iptables.ChainInfo
      Severity: Minor
      Found in libnetwork/drivers/bridge/bridge_linux.go - About 2 hrs to fix

        cnmNetworkAllocator has 25 methods (exceeds 20 allowed). Consider refactoring.
        Open

        type cnmNetworkAllocator struct {
            // The plugin getter instance used to get network and IPAM driver plugins.
            pg plugingetter.PluginGetter
        
            // The driver registry for all internal and external IPAM drivers.
        Severity: Minor
        Found in libnetwork/cnmallocator/networkallocator.go - About 2 hrs to fix

          containerConfig has 25 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type containerConfig struct {
              task                *api.Task
              networksAttachments map[string]*api.NetworkAttachment
          }
          Severity: Minor
          Found in daemon/cluster/executor/container/container.go - About 2 hrs to fix

            Method client.newStdioPipes has 95 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (c *client) newStdioPipes(fifos *cio.FIFOSet) (_ *stdioPipes, err error) {
                p := &stdioPipes{}
                if fifos.Stdin != "" {
                    c.logger.WithField("stdin", fifos.Stdin).Debug("listen")
                    l, err := winio.ListenPipe(fifos.Stdin, nil)
            Severity: Major
            Found in libcontainerd/remote/client_io_windows.go - About 2 hrs to fix

              Method task.Exec has 95 lines of code (exceeds 50 allowed). Consider refactoring.
              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 2 hrs to fix

                Method Daemon.foldFilter has 95 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (daemon *Daemon) foldFilter(ctx context.Context, view *container.View, config *containertypes.ListOptions) (*listContext, error) {
                    psFilters := config.Filters
                
                    var filtExited []int
                
                
                Severity: Major
                Found in daemon/list.go - About 2 hrs to fix

                  Method cmdProbe.run has 94 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (p *cmdProbe) run(ctx context.Context, d *Daemon, cntr *container.Container) (*containertypes.HealthcheckResult, error) {
                      startTime := time.Now()
                      cmdSlice := strslice.StrSlice(cntr.Config.Healthcheck.Test)[1:]
                      if p.shell {
                          cmdSlice = append(getShell(cntr), cmdSlice...)
                  Severity: Major
                  Found in daemon/health.go - About 2 hrs to fix

                    Method container.NewTask has 94 lines of code (exceeds 50 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: Major
                    Found in libcontainerd/local/local_windows.go - About 2 hrs to fix

                      Method LayerUploadManager.makeUploadFunc has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (lum *LayerUploadManager) makeUploadFunc(descriptor UploadDescriptor) doFunc {
                          return func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) transfer {
                              u := &uploadTransfer{
                                  transfer: newTransfer(),
                              }
                      Severity: Minor
                      Found in distribution/xfer/upload.go - About 2 hrs 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 Client.doRequest has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (cli *Client) doRequest(req *http.Request) (serverResponse, error) {
                          serverResp := serverResponse{statusCode: -1, reqURL: req.URL}
                      
                          resp, err := cli.client.Do(req)
                          if err != nil {
                      Severity: Minor
                      Found in client/request.go - About 2 hrs 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 normalizeLayersAndHistory has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func normalizeLayersAndHistory(diffs []digest.Digest, history []ocispec.History, ref cache.ImmutableRef) ([]digest.Digest, []ocispec.History) {
                          refMeta := getRefMetadata(ref, len(diffs))
                          var historyLayers int
                          for _, h := range history {
                              if !h.EmptyLayer {
                      Severity: Minor
                      Found in builder/builder-next/exporter/mobyexporter/writer.go - About 2 hrs 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 containerAdapter.pullImage has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (c *containerAdapter) pullImage(ctx context.Context) error {
                          spec := c.container.spec()
                      
                          // Skip pulling if the image is referenced by image ID.
                          if _, err := digest.Parse(spec.Image); err == nil {
                      Severity: Minor
                      Found in daemon/cluster/executor/container/adapter.go - About 2 hrs 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.manifestMatchesPlatform has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (i *ImageService) manifestMatchesPlatform(ctx context.Context, img *image.Image, platform ocispec.Platform) (bool, error) {
                          ls, err := i.leases.ListResources(ctx, leases.Lease{ID: imageKey(img.ID().String())})
                          if err != nil {
                              if cerrdefs.IsNotFound(err) {
                                  return false, nil
                      Severity: Minor
                      Found in daemon/images/image.go - About 2 hrs 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 Config.CopyStreams has 93 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (c *Config) CopyStreams(ctx context.Context, cfg *AttachConfig) <-chan error {
                          var group errgroup.Group
                      
                          // Connect stdin of container to the attach stdin stream.
                          if cfg.Stdin != nil {
                      Severity: Major
                      Found in container/stream/attach.go - About 2 hrs to fix

                        EndpointRecord has 24 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                        type EndpointRecord struct {
                            // Name of the container
                            Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
                            // Service name of the service to which this endpoint belongs.
                            ServiceName string `protobuf:"bytes,2,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty"`
                        Severity: Minor
                        Found in libnetwork/agent.pb.go - About 2 hrs to fix

                          Method IPTable.ProgramChain has 91 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (iptable IPTable) ProgramChain(c *ChainInfo, bridgeName string, hairpinMode, enable bool) error {
                              if c.Name == "" {
                                  return errors.New("could not program chain, missing chain name")
                              }
                          
                          
                          Severity: Major
                          Found in libnetwork/iptables/iptables.go - About 2 hrs to fix

                            Method Manager.CreateFromContext has 90 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (pm *Manager) CreateFromContext(ctx context.Context, tarCtx io.ReadCloser, options *types.PluginCreateOptions) (err error) {
                                pm.muGC.RLock()
                                defer pm.muGC.RUnlock()
                            
                                ref, err := reference.ParseNormalizedNamed(options.RepoName)
                            Severity: Major
                            Found in plugin/backend_linux.go - About 2 hrs to fix

                              Method ImageService.ImageHistory has 90 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func (i *ImageService) ImageHistory(ctx context.Context, name string, platform *ocispec.Platform) ([]*imagetype.HistoryResponseItem, error) {
                                  start := time.Now()
                                  img, err := i.resolveImage(ctx, name)
                                  if err != nil {
                                      return nil, err
                              Severity: Major
                              Found in daemon/containerd/image_history.go - About 2 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language