dotcloud/docker

View on GitHub

Showing 1,885 of 1,885 total issues

Method Daemon.setupMounts has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring.
Open

func (daemon *Daemon) setupMounts(ctx context.Context, c *container.Container) ([]container.Mount, func(context.Context) error, error) {
    var mounts []container.Mount
    // TODO: tmpfs mounts should be part of Mountpoints
    tmpfsMounts := make(map[string]bool)
    tmpfsMountInfo, err := c.TmpfsMounts()
Severity: Minor
Found in daemon/volumes_unix.go - About 4 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.createSpec has a Cognitive Complexity of 45 (exceeds 20 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: Minor
Found in daemon/oci_windows.go - About 4 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 UnpackLayer has 135 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func UnpackLayer(dest string, layer io.Reader, options *TarOptions) (size int64, err error) {
    tr := tar.NewReader(layer)
    trBuf := pools.BufioReader32KPool.Get(tr)
    defer pools.BufioReader32KPool.Put(trBuf)

Severity: Major
Found in pkg/archive/diff.go - About 4 hrs to fix

    File service.go has 599 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package convert // import "github.com/docker/docker/daemon/cluster/convert"
    
    import (
        "fmt"
        "strings"
    Severity: Minor
    Found in daemon/cluster/convert/service.go - About 4 hrs to fix

      Method puller.pullSchema2Layers has 134 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (p *puller) pullSchema2Layers(ctx context.Context, target distribution.Descriptor, layers []distribution.Descriptor, platform *ocispec.Platform) (id digest.Digest, err error) {
          if _, err := p.config.ImageStore.Get(ctx, target.Digest); err == nil {
              // If the image already exists locally, no need to pull
              // anything.
              return target.Digest, nil
      Severity: Major
      Found in distribution/pull_v2.go - About 4 hrs to fix

        Method PeerRecord.Unmarshal has 134 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

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

          Method Endpoint.sbJoin has 133 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (ep *Endpoint) sbJoin(ctx context.Context, sb *Sandbox, options ...EndpointOption) (err error) {
              ctx, span := otel.Tracer("").Start(ctx, "libnetwork.sbJoin")
              defer span.End()
          
              n, err := ep.getNetworkFromStore()
          Severity: Major
          Found in libnetwork/endpoint.go - About 4 hrs to fix

            Method Daemon.initNetworkController has 133 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (daemon *Daemon) initNetworkController(daemonCfg *config.Config, activeSandboxes map[string]interface{}) error {
                netOptions, err := daemon.networkOptions(daemonCfg, nil, daemon.id, nil)
                if err != nil {
                    return err
                }
            Severity: Major
            Found in daemon/daemon_windows.go - About 4 hrs to fix

              Function containerToGRPC has 133 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func containerToGRPC(c *types.ContainerSpec) (*swarmapi.ContainerSpec, error) {
                  containerSpec := &swarmapi.ContainerSpec{
                      Image:          c.Image,
                      Labels:         c.Labels,
                      Command:        c.Command,
              Severity: Major
              Found in daemon/cluster/convert/container.go - About 4 hrs to fix

                Method NetworkPushPull.Unmarshal has 132 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

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

                  Function FilterNetworks has a Cognitive Complexity of 44 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func FilterNetworks(nws []network.Inspect, filter filters.Args) ([]network.Inspect, error) {
                      // if filter is empty, return original network list
                      if filter.Len() == 0 {
                          return nws, nil
                      }
                  Severity: Minor
                  Found in daemon/network/filter.go - About 4 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

                  func createVlanLink(parentName string) error {
                      if strings.Contains(parentName, ".") {
                          parent, vidInt, err := parseVlan(parentName)
                          if err != nil {
                              return err
                  Severity: Major
                  Found in libnetwork/drivers/macvlan/macvlan_setup.go and 1 other location - About 4 hrs to fix
                  libnetwork/drivers/ipvlan/ipvlan_setup.go on lines 96..131

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

                  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

                  func createVlanLink(parentName string) error {
                      if strings.Contains(parentName, ".") {
                          parent, vidInt, err := parseVlan(parentName)
                          if err != nil {
                              return err
                  Severity: Major
                  Found in libnetwork/drivers/ipvlan/ipvlan_setup.go and 1 other location - About 4 hrs to fix
                  libnetwork/drivers/macvlan/macvlan_setup.go on lines 76..111

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

                  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 Daemon.containerStart has 130 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (daemon *Daemon) containerStart(ctx context.Context, daemonCfg *configStore, container *container.Container, checkpoint string, checkpointDir string, resetRestartManager bool) (retErr error) {
                      ctx, span := otel.Tracer("").Start(ctx, "daemon.containerStart", trace.WithAttributes(
                          attribute.String("container.ID", container.ID),
                          attribute.String("container.Name", container.Name)))
                      defer span.End()
                  Severity: Major
                  Found in daemon/start.go - About 4 hrs to fix

                    File cluster.go has 591 lines of code (exceeds 500 allowed). Consider refactoring.
                    Open

                    package networkdb
                    
                    import (
                        "bytes"
                        "context"
                    Severity: Minor
                    Found in libnetwork/networkdb/cluster.go - About 4 hrs to fix

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

                      func (d *driver) populateEndpoints() error {
                          kvol, err := d.store.List(&endpoint{})
                          if err != nil && err != datastore.ErrKeyNotFound {
                              return fmt.Errorf("failed to get macvlan endpoints from store: %v", err)
                          }
                      Severity: Major
                      Found in libnetwork/drivers/macvlan/macvlan_store.go and 1 other location - About 4 hrs to fix
                      libnetwork/drivers/ipvlan/ipvlan_store.go on lines 85..111

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

                      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

                      func (d *driver) populateEndpoints() error {
                          kvol, err := d.store.List(&endpoint{})
                          if err != nil && err != datastore.ErrKeyNotFound {
                              return fmt.Errorf("failed to get ipvlan endpoints from store: %v", err)
                          }
                      Severity: Major
                      Found in libnetwork/drivers/ipvlan/ipvlan_store.go and 1 other location - About 4 hrs to fix
                      libnetwork/drivers/macvlan/macvlan_store.go on lines 84..110

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

                      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 TableEvent.Unmarshal has 48 return statements (exceeds 4 allowed).
                      Open

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

                        File container.go has 590 lines of code (exceeds 500 allowed). Consider refactoring.
                        Open

                        package container // import "github.com/docker/docker/daemon/cluster/executor/container"
                        
                        import (
                            "context"
                            "encoding/json"
                        Severity: Minor
                        Found in daemon/cluster/executor/container/container.go - About 4 hrs to fix

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

                              if fifos.Stdin != "" {
                                  c.logger.WithField("stdin", fifos.Stdin).Debug("listen")
                                  l, err := winio.ListenPipe(fifos.Stdin, nil)
                                  if err != nil {
                                      return nil, errors.Wrapf(err, "failed to create stdin pipe %s", fifos.Stdin)
                          Severity: Major
                          Found in libcontainerd/remote/client_io_windows.go and 1 other location - About 4 hrs to fix
                          libcontainerd/remote/client_io_windows.go on lines 127..158

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

                          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