dotcloud/docker

View on GitHub

Showing 1,885 of 1,885 total issues

Method View.transform has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
Open

func (v *View) transform(container *Container) *Snapshot {
    health := types.NoHealthcheck
    if container.Health != nil {
        health = container.Health.Status()
    }
Severity: Minor
Found in container/view.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 networkRouter.getNetwork has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
Open

func (n *networkRouter) getNetwork(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/network/network_routes.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.pullTag has a Cognitive Complexity of 41 (exceeds 20 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: Minor
Found in daemon/containerd/image_pull.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 LocalRegistry.Scan has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
Open

func (l *LocalRegistry) Scan() ([]string, error) {
    var names []string
    dirEntries, err := os.ReadDir(l.socketsPath)
    if err != nil && !os.IsNotExist(err) {
        return nil, errors.Wrap(err, "error reading dir entries")
Severity: Minor
Found in pkg/plugins/discovery.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 builder.go has 572 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package buildkit

import (
    "context"
    "fmt"
Severity: Minor
Found in builder/builder-next/builder.go - About 3 hrs to fix

    Method driver.CreateEndpoint has 118 lines of code (exceeds 50 allowed). Consider refactoring.
    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 3 hrs to fix

      Method PartialLogEntryMetadata.Unmarshal has 118 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (m *PartialLogEntryMetadata) Unmarshal(dAtA []byte) error {
          l := len(dAtA)
          iNdEx := 0
          for iNdEx < l {
              preIndex := iNdEx
      Severity: Major
      Found in api/types/plugins/logdriver/entry.pb.go - About 3 hrs to fix

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

            for _, port := range ports {
                portProto := lntypes.ParseProtocol(port.Proto())
                portNum := uint16(port.Int())
                exposedPorts = append(exposedPorts, lntypes.TransportPort{
                    Proto: portProto,
        Severity: Major
        Found in daemon/network.go and 1 other location - About 3 hrs to fix
        daemon/container_operations.go on lines 124..156

        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 291.

        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

            for _, port := range ports {
                portProto := types.ParseProtocol(port.Proto())
                portNum := uint16(port.Int())
                exposedPorts = append(exposedPorts, types.TransportPort{
                    Proto: portProto,
        Severity: Major
        Found in daemon/container_operations.go and 1 other location - About 3 hrs to fix
        daemon/network.go on lines 941..973

        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 291.

        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

        Method NodeEvent.Unmarshal has 117 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (m *NodeEvent) 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

          swarmRouter has 30 methods (exceeds 20 allowed). Consider refactoring.
          Open

          func (sr *swarmRouter) initCluster(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
              var req types.InitRequest
              if err := httputils.ReadJSON(r, &req); err != nil {
                  return err
              }
          Severity: Minor
          Found in api/server/router/swarm/cluster_routes.go - About 3 hrs to fix

            Function splitConfigRootFSFromTar has a Cognitive Complexity of 40 (exceeds 20 allowed). Consider refactoring.
            Open

            func splitConfigRootFSFromTar(in io.ReadCloser, config *[]byte) io.ReadCloser {
                pr, pw := io.Pipe()
                go func() {
                    tarReader := tar.NewReader(in)
                    tarWriter := tar.NewWriter(pw)
            Severity: Minor
            Found in plugin/backend_linux.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 Controller.handleKeyChange has a Cognitive Complexity of 40 (exceeds 20 allowed). Consider refactoring.
            Open

            func (c *Controller) handleKeyChange(keys []*types.EncryptionKey) error {
                drvEnc := discoverapi.DriverEncryptionUpdate{}
            
                agent := c.getAgent()
                if agent == nil {
            Severity: Minor
            Found in libnetwork/agent.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 WithDevices has a Cognitive Complexity of 40 (exceeds 20 allowed). Consider refactoring.
            Open

            func WithDevices(daemon *Daemon, c *container.Container) coci.SpecOpts {
                return func(ctx context.Context, _ coci.Client, _ *containers.Container, s *coci.Spec) error {
                    // Build lists of devices allowed and created within the container.
                    var devs []specs.LinuxDevice
                    devPermissions := s.Linux.Resources.Devices
            Severity: Minor
            Found in daemon/oci_linux.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.resolveImage has a Cognitive Complexity of 40 (exceeds 20 allowed). Consider refactoring.
            Open

            func (i *ImageService) resolveImage(ctx context.Context, refOrID string) (containerdimages.Image, error) {
                parsed, err := reference.ParseAnyReference(refOrID)
                if err != nil {
                    return containerdimages.Image{}, errdefs.InvalidParameter(err)
                }
            Severity: Minor
            Found in daemon/containerd/image.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 View.transform has 114 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (v *View) transform(container *Container) *Snapshot {
                health := types.NoHealthcheck
                if container.Health != nil {
                    health = container.Health.Status()
                }
            Severity: Major
            Found in container/view.go - About 3 hrs to fix

              Method Daemon.ProcessEvent has 114 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei libcontainerdtypes.EventInfo) error {
                  c, err := daemon.GetContainer(id)
                  if err != nil {
                      return errors.Wrapf(err, "could not find container %s", id)
                  }
              Severity: Major
              Found in daemon/monitor.go - About 3 hrs to fix

                Method ImageService.Images has 113 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (i *ImageService) Images(ctx context.Context, opts imagetypes.ListOptions) ([]*imagetypes.Summary, error) {
                    if err := opts.Filters.Validate(acceptedImageFilterTags); err != nil {
                        return nil, err
                    }
                
                
                Severity: Major
                Found in daemon/containerd/image_list.go - About 3 hrs to fix

                  Daemon has 29 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (daemon *Daemon) NetworkControllerEnabled() bool {
                      return daemon.netController != nil
                  }
                  Severity: Minor
                  Found in daemon/network.go - About 3 hrs to fix

                    Method pushDescriptor.Upload has 112 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (pd *pushDescriptor) Upload(ctx context.Context, progressOutput progress.Output) (distribution.Descriptor, error) {
                        // Skip foreign layers unless this registry allows nondistributable artifacts.
                        if !pd.endpoint.AllowNondistributableArtifacts {
                            if fs, ok := pd.layer.(distribution.Describable); ok {
                                if d := fs.Descriptor(); len(d.URLs) > 0 {
                    Severity: Major
                    Found in distribution/push_v2.go - About 3 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language