dotcloud/docker

View on GitHub

Showing 1,885 of 1,885 total issues

Method ImageService.imageSummary has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
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) {

    // Total size of the image including all its platform
Severity: Minor
Found in daemon/containerd/image_list.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 container.createIO has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
Open

func (c *container) createIO(fifos *cio.FIFOSet, stdinCloseSync chan containerd.Process, attachStdio libcontainerdtypes.StdioCallback) (cio.IO, error) {
    var (
        io  *cio.DirectIO
        err error
    )
Severity: Minor
Found in libcontainerd/remote/client.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 Cluster.Init has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
Open

func (c *Cluster) Init(req types.InitRequest) (string, error) {
    c.controlMutex.Lock()
    defer c.controlMutex.Unlock()
    if c.nr != nil {
        if req.ForceNewCluster {
Severity: Minor
Found in daemon/cluster/swarm.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 Cluster.resolveSystemAddr has a Cognitive Complexity of 36 (exceeds 20 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 := netlink.LinkList()
    if err != nil {
Severity: Minor
Found in daemon/cluster/listen_addr_linux.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 Daemon.ContainerExecStart has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
Open

func (daemon *Daemon) ContainerExecStart(ctx context.Context, name string, options backend.ExecStartConfig) (err error) {
    var (
        cStdin           io.ReadCloser
        cStdout, cStderr io.Writer
    )
Severity: Minor
Found in daemon/exec.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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    t.ctr.client.eventQ.Append(t.ctr.id, func() {
        err := t.ctr.client.backend.ProcessEvent(t.ctr.id, libcontainerdtypes.EventResumed, libcontainerdtypes.EventInfo{
            ContainerID: t.ctr.id,
            ProcessID:   t.id,
        })
Severity: Major
Found in libcontainerd/local/local_windows.go and 1 other location - About 2 hrs to fix
libcontainerd/local/local_windows.go on lines 796..811

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 245.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    t.ctr.client.eventQ.Append(t.ctr.id, func() {
        err := t.ctr.client.backend.ProcessEvent(t.ctr.id, libcontainerdtypes.EventPaused, libcontainerdtypes.EventInfo{
            ContainerID: t.ctr.id,
            ProcessID:   t.id,
        })
Severity: Major
Found in libcontainerd/local/local_windows.go and 1 other location - About 2 hrs to fix
libcontainerd/local/local_windows.go on lines 837..852

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 245.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function StdCopy has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
Open

func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error) {
    var (
        buf       = make([]byte, startingBufLen)
        bufLen    = len(buf)
        nr, nw    int
Severity: Minor
Found in pkg/stdcopy/stdcopy.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 skipOverlay has 97 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func skipOverlay(dAtA []byte) (n int, err error) {
    l := len(dAtA)
    iNdEx := 0
    for iNdEx < l {
        var wire uint64
Severity: Major
Found in libnetwork/drivers/windows/overlay/overlay.pb.go - About 2 hrs to fix

    Method ImageService.pullTag has 97 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (i *ImageService) pullTag(ctx context.Context, ref reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registrytypes.AuthConfig, out progress.Output) error {
        var opts []containerd.RemoteOpt
        if platform != nil {
            opts = append(opts, containerd.WithPlatform(platforms.Format(*platform)))
        }
    Severity: Major
    Found in daemon/containerd/image_pull.go - About 2 hrs to fix

      Method imageRouter.postImagesCreate has 96 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (ir *imageRouter) postImagesCreate(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 2 hrs to fix

        Method Cluster.Init has 96 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (c *Cluster) Init(req types.InitRequest) (string, error) {
            c.controlMutex.Lock()
            defer c.controlMutex.Unlock()
            if c.nr != nil {
                if req.ForceNewCluster {
        Severity: Major
        Found in daemon/cluster/swarm.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

            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

              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

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                                    if os.Getenv("DOCKER_SERVICE_PREFER_OFFLINE_IMAGE") != "1" && queryRegistry {
                                        digestImage, err := c.imageWithDigestString(ctx, newCtnr.Image, authConfig)
                                        if err != nil {
                                            log.G(ctx).Warnf("unable to pin image %s to digest: %s", newCtnr.Image, err.Error())
                                            // warning in the client response should be concise
                        Severity: Major
                        Found in daemon/cluster/services.go and 1 other location - About 2 hrs to fix
                        daemon/cluster/services.go on lines 247..270

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 238.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Severity
                        Category
                        Status
                        Source
                        Language