dotcloud/docker

View on GitHub

Showing 1,468 of 1,914 total issues

Method ImageService.createDiff has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
Open

func (i *ImageService) createDiff(ctx context.Context, name string, sn snapshots.Snapshotter, cs content.Store, comparer diff.Comparer) (*ocispec.Descriptor, digest.Digest, error) {
    info, err := sn.Stat(ctx, name)
    if err != nil {
        return nil, "", err
    }
Severity: Minor
Found in daemon/containerd/image_commit.go - About 3 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 layerDescriptor.Download has 106 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (ld *layerDescriptor) Download(ctx context.Context, progressOutput progress.Output) (io.ReadCloser, int64, error) {
    log.G(ctx).Debugf("pulling blob %q", ld.digest)

    var (
        err    error
Severity: Major
Found in distribution/pull_v2.go - About 3 hrs to fix

    Method imageExporterInstance.Export has 106 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (e *imageExporterInstance) Export(ctx context.Context, inp *exporter.Source, inlineCache exptypes.InlineCache, sessionID string) (map[string]string, exporter.DescriptorReference, error) {
        if len(inp.Refs) > 1 {
            return nil, nil, fmt.Errorf("exporting multiple references to image store is currently unsupported")
        }
    
    
    Severity: Major
    Found in builder/builder-next/exporter/mobyexporter/export.go - About 3 hrs to fix

      Method Daemon.ContainerLogs has 106 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (daemon *Daemon) ContainerLogs(ctx context.Context, containerName string, config *containertypes.LogsOptions) (messages <-chan *backend.LogMessage, isTTY bool, retErr error) {
          ctx, span := tracing.StartSpan(ctx, "daemon.ContainerLogs")
          defer func() {
              span.SetStatus(retErr)
              span.End()
      Severity: Major
      Found in daemon/logs.go - About 3 hrs to fix

        File sandbox.go has 550 lines of code (exceeds 500 allowed). Consider refactoring.
        Open

        package libnetwork
        
        import (
            "context"
            "encoding/json"
        Severity: Minor
        Found in libnetwork/sandbox.go - About 3 hrs to fix

          Method Daemon.createSpec has 105 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (daemon *Daemon) createSpec(ctx context.Context, daemonCfg *configStore, c *container.Container, mounts []container.Mount) (*specs.Spec, error) {
              img, err := daemon.imageService.GetImage(ctx, string(c.ImageID), backend.GetImageOpts{})
              if err != nil {
                  return nil, err
              }
          Severity: Major
          Found in daemon/oci_windows.go - About 3 hrs to fix

            Method driver.CreateNetwork has 103 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error {
                var (
                    networkName   string
                    interfaceName string
                    staleNetworks []string
            Severity: Major
            Found in libnetwork/drivers/windows/overlay/ov_network_windows.go - About 3 hrs to fix

              Method Daemon.createNetwork has 103 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (daemon *Daemon) createNetwork(cfg *config.Config, create networktypes.CreateRequest, id string, agent bool) (*networktypes.CreateResponse, error) {
                  if network.IsPredefined(create.Name) {
                      return nil, PredefinedNetworkError(create.Name)
                  }
              
              
              Severity: Major
              Found in daemon/network.go - About 3 hrs to fix

                Method Endpoint.UnmarshalJSON has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
                Open

                func (ep *Endpoint) UnmarshalJSON(b []byte) (err error) {
                    ep.mu.Lock()
                    defer ep.mu.Unlock()
                
                    var epMap map[string]interface{}
                Severity: Minor
                Found in libnetwork/endpoint.go - About 3 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.pushRef has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
                Open

                func (i *ImageService) pushRef(ctx context.Context, targetRef reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, out progress.Output) (retErr error) {
                    leasedCtx, release, err := i.client.WithLease(ctx)
                    if err != nil {
                        return err
                    }
                Severity: Minor
                Found in daemon/containerd/image_push.go - About 3 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 buildCreateEndpointOptions has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
                Open

                func buildCreateEndpointOptions(c *container.Container, n *libnetwork.Network, epConfig *network.EndpointSettings, sb *libnetwork.Sandbox, daemonDNS []string) ([]libnetwork.EndpointOption, error) {
                    var createOptions []libnetwork.EndpointOption
                    genericOptions := make(options.Generic)
                
                    nwName := n.Name()
                Severity: Minor
                Found in daemon/network.go - About 3 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 Daemon.connectToNetwork has a Cognitive Complexity of 37 (exceeds 20 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: Minor
                Found in daemon/container_operations.go - About 3 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

                File encryption.go has 545 lines of code (exceeds 500 allowed). Consider refactoring.
                Open

                //go:build linux
                
                package overlay
                
                import (
                Severity: Minor
                Found in libnetwork/drivers/overlay/encryption.go - About 3 hrs to fix

                  Method ImageService.pushRef has 102 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (i *ImageService) pushRef(ctx context.Context, targetRef reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, out progress.Output) (retErr error) {
                      leasedCtx, release, err := i.client.WithLease(ctx)
                      if err != nil {
                          return err
                      }
                  Severity: Major
                  Found in daemon/containerd/image_push.go - About 3 hrs to fix

                    Method ImageService.resolveAllReferences has 102 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (i *ImageService) resolveAllReferences(ctx context.Context, refOrID string) (*containerdimages.Image, []containerdimages.Image, error) {
                        parsed, err := reference.ParseAnyReference(refOrID)
                        if err != nil {
                            return nil, nil, errdefs.InvalidParameter(err)
                        }
                    Severity: Major
                    Found in daemon/containerd/image.go - About 3 hrs to fix

                      Method ImageService.ImagesPrune has 102 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (i *ImageService) ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*imagetypes.PruneReport, error) {
                          if !i.pruneRunning.CompareAndSwap(false, true) {
                              return nil, errPruneRunning
                          }
                          defer i.pruneRunning.Store(false)
                      Severity: Major
                      Found in daemon/images/image_prune.go - About 3 hrs to fix

                        Method Endpoint.UnmarshalJSON has 101 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (ep *Endpoint) UnmarshalJSON(b []byte) (err error) {
                            ep.mu.Lock()
                            defer ep.mu.Unlock()
                        
                            var epMap map[string]interface{}
                        Severity: Major
                        Found in libnetwork/endpoint.go - About 3 hrs to fix

                          Method Copier.copySrc has 101 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (c *Copier) copySrc(name string, src io.Reader) {
                              defer c.copyJobs.Done()
                          
                              bufSize := defaultBufSize
                              if sizedLogger, ok := c.dst.(SizedLogger); ok {
                          Severity: Major
                          Found in daemon/logger/copier.go - About 3 hrs to fix

                            Method Controller.sandboxCleanup has 100 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (c *Controller) sandboxCleanup(activeSandboxes map[string]interface{}) error {
                                sandboxStates, err := c.store.List(&sbState{c: c})
                                if err != nil {
                                    if err == datastore.ErrKeyNotFound {
                                        // It's normal for no sandboxes to be found. Just bail out.
                            Severity: Major
                            Found in libnetwork/sandbox_store.go - About 3 hrs to fix

                              Method GossipMessage.Unmarshal has 100 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func (m *GossipMessage) Unmarshal(dAtA []byte) error {
                                  l := len(dAtA)
                                  iNdEx := 0
                                  for iNdEx < l {
                                      preIndex := iNdEx
                              Severity: Major
                              Found in libnetwork/networkdb/networkdb.pb.go - About 3 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language