dotcloud/docker

View on GitHub

Showing 1,468 of 1,914 total issues

Method Cluster.GetServices has 90 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (c *Cluster) GetServices(options types.ServiceListOptions) ([]swarm.Service, error) {
    c.mu.RLock()
    defer c.mu.RUnlock()

    state := c.currentNodeState()
Severity: Major
Found in daemon/cluster/services.go - About 2 hrs to fix

    Function volumeName has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
    Open

    func volumeName(path string) (v string) {
        if len(path) < 2 {
            return ""
        }
        // with drive letter
    Severity: Minor
    Found in daemon/logger/loggerutils/file_windows.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 LayerDownloadManager.Download has 89 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (ldm *LayerDownloadManager) Download(ctx context.Context, initialRootFS image.RootFS, layers []DownloadDescriptor, progressOutput progress.Output) (image.RootFS, func(), error) {
        var (
            topLayer       layer.Layer
            topDownload    *downloadTransfer
            watcher        *watcher
    Severity: Major
    Found in distribution/xfer/download.go - About 2 hrs to fix

      Method driver.Join has 89 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (d *driver) Join(ctx context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
          ctx, span := otel.Tracer("").Start(ctx, "libnetwork.drivers.overlay.Join", trace.WithAttributes(
              attribute.String("nid", nid),
              attribute.String("eid", eid),
              attribute.String("sboxKey", sboxKey)))
      Severity: Major
      Found in libnetwork/drivers/overlay/joinleave.go - About 2 hrs to fix

        Method client.processEventStream has 89 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (c *client) processEventStream(ctx context.Context, ns string) {
            // Create a new context specifically for this subscription.
            // The context must be cancelled to cancel the subscription.
            // In cases where we have to restart event stream processing,
            //   we'll need the original context b/c this one will be cancelled
        Severity: Major
        Found in libcontainerd/remote/client.go - About 2 hrs to fix

          Method ImageService.createDiff has 89 lines of code (exceeds 50 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: Major
          Found in daemon/containerd/image_commit.go - About 2 hrs to fix

            Method walker.walk has 89 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (w *walker) walk(path string, i1, i2 os.FileInfo) (err error) {
                // Register these nodes with the return trees, unless we're still at the
                // (already-created) roots:
                if path != "/" {
                    if err := walkchunk(path, i1, w.dir1, w.root1); err != nil {
            Severity: Major
            Found in pkg/archive/changes_linux.go - About 2 hrs to fix

              Function verifyPlatformContainerResources has 88 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func verifyPlatformContainerResources(resources *containertypes.Resources, isHyperv bool) (warnings []string, err error) {
                  fixMemorySwappiness(resources)
                  if !isHyperv {
                      // The processor resource controls are mutually exclusive on
                      // Windows Server Containers, the order of precedence is
              Severity: Major
              Found in daemon/daemon_windows.go - About 2 hrs to fix

                Method Daemon.statsV2 has 88 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (daemon *Daemon) statsV2(s *containertypes.StatsResponse, stats *statsV2.Metrics) (*containertypes.StatsResponse, error) {
                    if stats.Io != nil {
                        var isbr []containertypes.BlkioStatEntry
                        for _, re := range stats.Io.Usage {
                            isbr = append(isbr,
                Severity: Major
                Found in daemon/stats_unix.go - About 2 hrs to fix

                  Method ImageService.manifestMatchesPlatform has 88 lines of code (exceeds 50 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: Major
                  Found in daemon/images/image.go - About 2 hrs to fix

                    Function merge has 88 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func merge(userConf, imageConf *containertypes.Config) error {
                        if userConf.User == "" {
                            userConf.User = imageConf.User
                        }
                        if len(userConf.ExposedPorts) == 0 {
                    Severity: Major
                    Found in daemon/commit.go - About 2 hrs to fix

                      layerStore has 23 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      type layerStore struct {
                          store  *fileMetadataStore
                          driver graphdriver.Driver
                      
                          layerMap map[ChainID]*roLayer
                      Severity: Minor
                      Found in layer/layer_store.go - About 2 hrs to fix

                        Method Controller.handleKeyChange has 87 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (c *Controller) handleKeyChange(keys []*types.EncryptionKey) error {
                            drvEnc := discoverapi.DriverEncryptionUpdate{}
                        
                            agent := c.getAgent()
                            if agent == nil {
                        Severity: Major
                        Found in libnetwork/agent.go - About 2 hrs to fix

                          Method ImageService.ImageInspect has 87 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (i *ImageService) ImageInspect(ctx context.Context, refOrID string, _ backend.ImageInspectOpts) (*imagetypes.InspectResponse, error) {
                              img, err := i.GetImage(ctx, refOrID, backend.GetImageOpts{})
                              if err != nil {
                                  return nil, err
                              }
                          Severity: Major
                          Found in daemon/containerd/image_inspect.go - About 2 hrs to fix

                            Method Endpoint.sbLeave has 86 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (ep *Endpoint) sbLeave(ctx context.Context, sb *Sandbox, force bool) error {
                                n, err := ep.getNetworkFromStore()
                                if err != nil {
                                    return fmt.Errorf("failed to get network from store during leave: %v", err)
                                }
                            Severity: Major
                            Found in libnetwork/endpoint.go - About 2 hrs to fix

                              Function StartProxy has 86 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func StartProxy(pb types.PortBinding,
                                  proxyPath string,
                                  listenSock *os.File,
                              ) (stop func() error, retErr error) {
                                  if proxyPath == "" {
                              Severity: Major
                              Found in libnetwork/portmapper/proxy_linux.go - About 2 hrs to fix

                                Method Daemon.statsV1 has 86 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func (daemon *Daemon) statsV1(s *containertypes.StatsResponse, stats *statsV1.Metrics) (*containertypes.StatsResponse, error) {
                                    if stats.Blkio != nil {
                                        s.BlkioStats = containertypes.BlkioStats{
                                            IoServiceBytesRecursive: copyBlkioEntry(stats.Blkio.IoServiceBytesRecursive),
                                            IoServicedRecursive:     copyBlkioEntry(stats.Blkio.IoServicedRecursive),
                                Severity: Major
                                Found in daemon/stats_unix.go - About 2 hrs to fix

                                  Method addrSpace.allocatePredefinedPool has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
                                  Open

                                  func (aSpace *addrSpace) allocatePredefinedPool(reserved []netip.Prefix) (netip.Prefix, error) {
                                      aSpace.mu.Lock()
                                      defer aSpace.mu.Unlock()
                                  
                                      var pdfID int
                                  Severity: Minor
                                  Found in libnetwork/ipams/defaultipam/address_space.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 NetworkEvent.Unmarshal has 27 return statements (exceeds 4 allowed).
                                  Open

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

                                    Method NetworkEntry.Unmarshal has 27 return statements (exceeds 4 allowed).
                                    Open

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