dotcloud/docker

View on GitHub

Showing 1,885 of 1,885 total issues

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

    if fifos.Stderr != "" {
        c.logger.WithField("stderr", fifos.Stderr).Debug("listen")
        l, err := winio.ListenPipe(fifos.Stderr, nil)
        if err != nil {
            return nil, errors.Wrapf(err, "failed to create stderr pipe %s", fifos.Stderr)
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 61..92

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

Method Controller.sandboxCleanup has a Cognitive Complexity of 43 (exceeds 20 allowed). Consider refactoring.
Open

func (c *Controller) sandboxCleanup(activeSandboxes map[string]interface{}) error {
    sandboxStates, err := c.store.List(&sbState{c: c})
    if err != nil {
        if err == datastore.ErrKeyNotFound {
            // It's normal for no sandboxes to be found. Just bail out.
Severity: Minor
Found in libnetwork/sandbox_store.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 driver.link has a Cognitive Complexity of 43 (exceeds 20 allowed). Consider refactoring.
Open

func (d *driver) link(network *bridgeNetwork, endpoint *bridgeEndpoint, enable bool) (retErr error) {
    cc := endpoint.containerConfig
    ec := endpoint.extConnConfig
    if cc == nil || ec == nil || (len(cc.ParentEndpoints) == 0 && len(cc.ChildEndpoints) == 0) {
        // nothing to do
Severity: Minor
Found in libnetwork/drivers/bridge/bridge_linux.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 verifyPlatformContainerResources has a Cognitive Complexity of 43 (exceeds 20 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: Minor
Found in daemon/daemon_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

Method LayerDownloadManager.makeDownloadFunc has 127 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (ldm *LayerDownloadManager) makeDownloadFunc(descriptor DownloadDescriptor, parentLayer layer.ChainID, parentDownload *downloadTransfer) doFunc {
    return func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) transfer {
        d := &downloadTransfer{
            transfer:   newTransfer(),
            layerStore: ldm.layerStore,
Severity: Major
Found in distribution/xfer/download.go - About 4 hrs to fix

    Method Daemon.ContainerRename has 126 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (daemon *Daemon) ContainerRename(oldName, newName string) (retErr error) {
        if oldName == "" || newName == "" {
            return errdefs.InvalidParameter(errors.New("Neither old nor new names may be empty"))
        }
    
    
    Severity: Major
    Found in daemon/rename.go - About 4 hrs to fix

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

      func (d *driver) DeleteEndpoint(nid, eid string) error {
          if err := validateID(nid, eid); err != nil {
              return err
          }
          n := d.network(nid)
      Severity: Major
      Found in libnetwork/drivers/macvlan/macvlan_endpoint.go and 1 other location - About 4 hrs to fix
      libnetwork/drivers/ipvlan/ipvlan_endpoint.go on lines 64..87

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

      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) DeleteEndpoint(nid, eid string) error {
          if err := validateID(nid, eid); err != nil {
              return err
          }
          n := d.network(nid)
      Severity: Major
      Found in libnetwork/drivers/ipvlan/ipvlan_endpoint.go and 1 other location - About 4 hrs to fix
      libnetwork/drivers/macvlan/macvlan_endpoint.go on lines 69..94

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

      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 puller.pullTag has 124 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (p *puller) pullTag(ctx context.Context, ref reference.Named, platform *ocispec.Platform) (tagUpdated bool, err error) {
          var (
              tagOrDigest string // Used for logging/progress only
              dgst        digest.Digest
              mt          string
      Severity: Major
      Found in distribution/pull_v2.go - About 3 hrs to fix

        Method tarexporter.Load has 124 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (l *tarexporter) Load(ctx context.Context, inTar io.ReadCloser, outStream io.Writer, quiet bool) (outErr error) {
            ctx, span := tracing.StartSpan(ctx, "tarexport.Load")
            defer span.End()
            defer func() {
                span.SetStatus(outErr)
        Severity: Major
        Found in image/tarexport/load.go - About 3 hrs to fix

          Method Daemon.fillPlatformInfo has 124 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (daemon *Daemon) fillPlatformInfo(ctx context.Context, v *system.Info, sysInfo *sysinfo.SysInfo, cfg *configStore) error {
              v.CgroupDriver = cgroupDriver(&cfg.Config)
              v.CgroupVersion = "1"
              if sysInfo.CgroupUnified {
                  v.CgroupVersion = "2"
          Severity: Major
          Found in daemon/info_unix.go - About 3 hrs to fix

            Method cnmNetworkAllocator.IsServiceAllocated has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
            Open

            func (na *cnmNetworkAllocator) IsServiceAllocated(s *api.Service, flags ...func(*networkallocator.ServiceAllocationOpts)) bool {
                specNetworks := serviceNetworks(s)
            
                // If endpoint mode is VIP and allocator does not have the
                // service in VIP allocated set then it needs to be allocated.
            Severity: Minor
            Found in libnetwork/cnmallocator/networkallocator.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 adjustForAPIVersion has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
            Open

            func adjustForAPIVersion(cliVersion string, service *swarm.ServiceSpec) {
                if cliVersion == "" {
                    return
                }
                if versions.LessThan(cliVersion, "1.46") {
            Severity: Minor
            Found in api/server/router/swarm/helpers.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 imageExporterInstance.Export has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
            Open

            func (e *imageExporterInstance) Export(ctx context.Context, inp *exporter.Source, inlineCache exptypes.InlineCache, sessionID string) (map[string]string, exporter.DescriptorReference, error) {
                if len(inp.Refs) > 1 {
                    return nil, nil, fmt.Errorf("exporting multiple references to image store is currently unsupported")
                }
            
            
            Severity: Minor
            Found in builder/builder-next/exporter/mobyexporter/export.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.getSameReferences has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
            Open

            func (i *ImageService) getSameReferences(ctx context.Context, named reference.Named, imgs []images.Image) ([]images.Image, error) {
                var (
                    tag        string
                    sameRef    []images.Image
                    digestRefs = []images.Image{}
            Severity: Minor
            Found in daemon/containerd/image_delete.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 New has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
            Open

            func New(info logger.Info) (logger.Logger, error) {
                hostname, err := info.Hostname()
                if err != nil {
                    return nil, fmt.Errorf("%s: cannot access hostname to set source field", driverName)
                }
            Severity: Minor
            Found in daemon/logger/splunk/splunk.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 Daemon.containerAttach has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
            Open

            func (daemon *Daemon) containerAttach(c *container.Container, cfg *stream.AttachConfig, logs, doStream bool) error {
                if logs {
                    logDriver, logCreated, err := daemon.getLogger(c)
                    if err != nil {
                        return err
            Severity: Minor
            Found in daemon/attach.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 toRootless has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
            Open

            func toRootless(spec *specs.Spec, v2Controllers []string, currentOOMScoreAdj int) error {
                if len(v2Controllers) == 0 {
                    if spec.Linux != nil {
                        // Remove cgroup settings.
                        spec.Linux.Resources = nil
            Severity: Minor
            Found in pkg/rootless/specconv/specconv_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

            Function containerSpecFromGRPC has 119 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func containerSpecFromGRPC(c *swarmapi.ContainerSpec) *types.ContainerSpec {
                if c == nil {
                    return nil
                }
                containerSpec := &types.ContainerSpec{
            Severity: Major
            Found in daemon/cluster/convert/container.go - About 3 hrs to fix

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

              func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error {
                  var (
                      networkName   string
                      interfaceName string
                      staleNetworks []string
              Severity: Minor
              Found in libnetwork/drivers/windows/overlay/ov_network_windows.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

              Severity
              Category
              Status
              Source
              Language