dotcloud/docker

View on GitHub

Showing 1,468 of 1,914 total issues

Method Sandbox.clearNetworkResources has 57 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (sb *Sandbox) clearNetworkResources(origEp *Endpoint) error {
    ep := sb.GetEndpoint(origEp.id)
    if ep == nil {
        return fmt.Errorf("could not find the sandbox endpoint data for endpoint %s",
            origEp.id)
Severity: Minor
Found in libnetwork/sandbox.go - About 1 hr to fix

    Function updateNodeKey has 57 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func updateNodeKey(lIP, aIP, rIP net.IP, idxs []*spi, curKeys []*key, newIdx, priIdx, delIdx int) []*spi {
        log.G(context.TODO()).Debugf("Updating keys for node: %s (%d,%d,%d)", rIP, newIdx, priIdx, delIdx)
    
        spis := idxs
        log.G(context.TODO()).Debugf("Current: %v", spis)
    Severity: Minor
    Found in libnetwork/drivers/overlay/encryption.go - About 1 hr to fix

      Function GetTimestamp has 57 lines of code (exceeds 50 allowed). Consider refactoring.
      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: Minor
      Found in api/types/time/timestamp.go - About 1 hr to fix

        Method Cluster.Join has 57 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (c *Cluster) Join(req types.JoinRequest) error {
            c.controlMutex.Lock()
            defer c.controlMutex.Unlock()
            c.mu.Lock()
            if c.nr != nil {
        Severity: Minor
        Found in daemon/cluster/swarm.go - About 1 hr to fix

          Method Cluster.resolveSystemAddr has 57 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (c *Cluster) resolveSystemAddr() (net.IP, error) {
              // Use the system's only device IP address, or fail if there are
              // multiple addresses to choose from.
              interfaces, err := nlwrap.LinkList()
              if err != nil {
          Severity: Minor
          Found in daemon/cluster/listen_addr_linux.go - About 1 hr to fix

            Method Cluster.AttachNetwork has 57 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (c *Cluster) AttachNetwork(target string, containerID string, addresses []string) (*network.NetworkingConfig, error) {
                aKey := attacherKey(target, containerID)
                c.mu.Lock()
                state := c.currentNodeState()
                if state.swarmNode == nil || state.swarmNode.Agent() == nil {
            Severity: Minor
            Found in daemon/cluster/networks.go - About 1 hr to fix

              Function ffjsonWriteJSONBytesAsString has 57 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func ffjsonWriteJSONBytesAsString(buf *bytes.Buffer, s []byte) {
                  const hex = "0123456789abcdef"
              
                  buf.WriteByte('"')
                  start := 0
              Severity: Minor
              Found in daemon/logger/jsonfilelog/jsonlog/jsonlogbytes.go - About 1 hr to fix

                Method Daemon.ContainerStats has 57 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (daemon *Daemon) ContainerStats(ctx context.Context, prefixOrName string, config *backend.ContainerStatsConfig) error {
                    ctr, err := daemon.GetContainer(prefixOrName)
                    if err != nil {
                        return err
                    }
                Severity: Minor
                Found in daemon/stats.go - About 1 hr to fix

                  Function StartProxy has 13 return statements (exceeds 4 allowed).
                  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 1 hr to fix

                    Method Root.validateOpts has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (r *Root) validateOpts(opts map[string]string) error {
                        if len(opts) == 0 {
                            return nil
                        }
                        for opt := range opts {
                    Severity: Minor
                    Found in volume/local/local_unix.go - About 1 hr 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 driver.CreateEndpoint has 13 return statements (exceeds 4 allowed).
                    Open

                    func (d *driver) CreateEndpoint(ctx context.Context, nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error {
                        ctx, span := otel.Tracer("").Start(ctx, fmt.Sprintf("libnetwork.drivers.windows_%s.CreateEndpoint", d.name), trace.WithAttributes(
                            attribute.String("nid", nid),
                            attribute.String("eid", eid)))
                        defer span.End()
                    Severity: Major
                    Found in libnetwork/drivers/windows/windows.go - About 1 hr to fix

                      Method containerRouter.postContainerExecStart has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (c *containerRouter) postContainerExecStart(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
                          if err := httputils.ParseForm(r); err != nil {
                              return err
                          }
                      
                      
                      Severity: Minor
                      Found in api/server/router/container/exec.go - About 1 hr 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.imageSummary has 13 return statements (exceeds 4 allowed).
                      Open

                      func (i *ImageService) imageSummary(ctx context.Context, img images.Image, platformMatcher platforms.MatchComparer,
                          opts imagetypes.ListOptions, tagsByDigest map[digest.Digest][]string,
                      ) (_ *imagetypes.Summary, allChainIDs []digest.Digest, _ error) {
                          var manifestSummaries []imagetypes.ManifestSummary
                      
                      
                      Severity: Major
                      Found in daemon/containerd/image_list.go - About 1 hr to fix

                        Method Daemon.ContainerLogs has 13 return statements (exceeds 4 allowed).
                        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 1 hr to fix

                          Method task.Exec has a Cognitive Complexity of 26 (exceeds 20 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: Minor
                          Found in libcontainerd/local/local_windows.go - About 1 hr 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 kernelSupportsRecursivelyReadOnly has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func kernelSupportsRecursivelyReadOnly() error {
                              fn := func() error {
                                  tmpMnt, err := os.MkdirTemp("", "moby-detect-rro")
                                  if err != nil {
                                      return fmt.Errorf("failed to create a temp directory: %w", err)
                          Severity: Minor
                          Found in daemon/daemon_linux.go - About 1 hr 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.GetImageAndReleasableLayer has 13 return statements (exceeds 4 allowed).
                          Open

                          func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error) {
                              if refOrID == "" { // FROM scratch
                                  if runtime.GOOS == "windows" {
                                      return nil, nil, fmt.Errorf(`"FROM scratch" is not supported on Windows`)
                                  }
                          Severity: Major
                          Found in daemon/containerd/image_builder.go - About 1 hr to fix

                            Function ffjsonWriteJSONBytesAsString has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                            Open

                            func ffjsonWriteJSONBytesAsString(buf *bytes.Buffer, s []byte) {
                                const hex = "0123456789abcdef"
                            
                                buf.WriteByte('"')
                                start := 0
                            Severity: Minor
                            Found in daemon/logger/jsonfilelog/jsonlog/jsonlogbytes.go - About 1 hr 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.containerExtractToDir has 13 return statements (exceeds 4 allowed).
                            Open

                            func (daemon *Daemon) containerExtractToDir(container *container.Container, path string, copyUIDGID, noOverwriteDirNonDir bool, content io.Reader) (err error) {
                                container.Lock()
                                defer container.Unlock()
                            
                                // Make sure an online file-system operation is permitted.
                            Severity: Major
                            Found in daemon/archive_windows.go - About 1 hr to fix

                              Function buildIPAMResources has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                              Open

                              func buildIPAMResources(nw *libnetwork.Network) networktypes.IPAM {
                                  var ipamConfig []networktypes.IPAMConfig
                              
                                  ipamDriver, ipamOptions, ipv4Conf, ipv6Conf := nw.IpamConfig()
                              
                              
                              Severity: Minor
                              Found in daemon/network.go - About 1 hr 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

                              Severity
                              Category
                              Status
                              Source
                              Language