dotcloud/docker

View on GitHub

Showing 1,904 of 1,904 total issues

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

func WithIPv4(networkName, ip string) func(*TestContainerConfig) {
    return func(c *TestContainerConfig) {
        if c.NetworkingConfig.EndpointsConfig == nil {
            c.NetworkingConfig.EndpointsConfig = map[string]*network.EndpointSettings{}
        }
Severity: Major
Found in integration/internal/container/ops.go and 1 other location - About 2 hrs to fix
integration/internal/container/ops.go on lines 172..185

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

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 WithIPv6(networkName, ip string) func(*TestContainerConfig) {
    return func(c *TestContainerConfig) {
        if c.NetworkingConfig.EndpointsConfig == nil {
            c.NetworkingConfig.EndpointsConfig = map[string]*network.EndpointSettings{}
        }
Severity: Major
Found in integration/internal/container/ops.go and 1 other location - About 2 hrs to fix
integration/internal/container/ops.go on lines 156..169

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

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 container.NewTask has 94 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (ctr *container) NewTask(_ context.Context, _ string, withStdin bool, attachStdio libcontainerdtypes.StdioCallback) (_ libcontainerdtypes.Task, retErr error) {
    ctr.mu.Lock()
    defer ctr.mu.Unlock()

    switch {
Severity: Major
Found in libcontainerd/local/local_windows.go - About 2 hrs to fix

    Method cmdProbe.run has 94 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (p *cmdProbe) run(ctx context.Context, d *Daemon, cntr *container.Container) (*containertypes.HealthcheckResult, error) {
        startTime := time.Now()
        cmdSlice := strslice.StrSlice(cntr.Config.Healthcheck.Test)[1:]
        if p.shell {
            cmdSlice = append(getShell(cntr), cmdSlice...)
    Severity: Major
    Found in daemon/health.go - About 2 hrs to fix

      Method LayerUploadManager.makeUploadFunc has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
      Open

      func (lum *LayerUploadManager) makeUploadFunc(descriptor UploadDescriptor) doFunc {
          return func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) transfer {
              u := &uploadTransfer{
                  transfer: newTransfer(),
              }
      Severity: Minor
      Found in distribution/xfer/upload.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 Client.doRequest has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
      Open

      func (cli *Client) doRequest(req *http.Request) (serverResponse, error) {
          serverResp := serverResponse{statusCode: -1, reqURL: req.URL}
      
          resp, err := cli.client.Do(req)
          if err != nil {
      Severity: Minor
      Found in client/request.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 normalizeLayersAndHistory has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
      Open

      func normalizeLayersAndHistory(diffs []digest.Digest, history []ocispec.History, ref cache.ImmutableRef) ([]digest.Digest, []ocispec.History) {
          refMeta := getRefMetadata(ref, len(diffs))
          var historyLayers int
          for _, h := range history {
              if !h.EmptyLayer {
      Severity: Minor
      Found in builder/builder-next/exporter/mobyexporter/writer.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 ImageService.LoadImage has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
      Open

      func (i *ImageService) LoadImage(ctx context.Context, inTar io.ReadCloser, platform *ocispec.Platform, outStream io.Writer, quiet bool) error {
          decompressed, err := dockerarchive.DecompressStream(inTar)
          if err != nil {
              return errors.Wrap(err, "failed to decompress input tar archive")
          }
      Severity: Minor
      Found in daemon/containerd/image_exporter.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 containerAdapter.pullImage has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
      Open

      func (c *containerAdapter) pullImage(ctx context.Context) error {
          spec := c.container.spec()
      
          // Skip pulling if the image is referenced by image ID.
          if _, err := digest.Parse(spec.Image); err == nil {
      Severity: Minor
      Found in daemon/cluster/executor/container/adapter.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 ImageService.manifestMatchesPlatform has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
      Open

      func (i *ImageService) manifestMatchesPlatform(ctx context.Context, img *image.Image, platform ocispec.Platform) (bool, error) {
          ls, err := i.leases.ListResources(ctx, leases.Lease{ID: imageKey(img.ID().String())})
          if err != nil {
              if cerrdefs.IsNotFound(err) {
                  return false, nil
      Severity: Minor
      Found in daemon/images/image.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 4 locations. Consider refactoring.
      Open

      package client // import "github.com/docker/docker/client"
      
      import (
          "context"
          "encoding/json"
      Severity: Major
      Found in client/image_prune.go and 3 other locations - About 2 hrs to fix
      client/container_prune.go on lines 1..36
      client/network_prune.go on lines 1..36
      client/volume_prune.go on lines 1..36

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

      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 4 locations. Consider refactoring.
      Open

      package client // import "github.com/docker/docker/client"
      
      import (
          "context"
          "encoding/json"
      Severity: Major
      Found in client/network_prune.go and 3 other locations - About 2 hrs to fix
      client/container_prune.go on lines 1..36
      client/image_prune.go on lines 1..36
      client/volume_prune.go on lines 1..36

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

      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 4 locations. Consider refactoring.
      Open

      package client // import "github.com/docker/docker/client"
      
      import (
          "context"
          "encoding/json"
      Severity: Major
      Found in client/volume_prune.go and 3 other locations - About 2 hrs to fix
      client/container_prune.go on lines 1..36
      client/image_prune.go on lines 1..36
      client/network_prune.go on lines 1..36

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

      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 4 locations. Consider refactoring.
      Open

      package client // import "github.com/docker/docker/client"
      
      import (
          "context"
          "encoding/json"
      Severity: Major
      Found in client/container_prune.go and 3 other locations - About 2 hrs to fix
      client/image_prune.go on lines 1..36
      client/network_prune.go on lines 1..36
      client/volume_prune.go on lines 1..36

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

      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 Config.CopyStreams has 93 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (c *Config) CopyStreams(ctx context.Context, cfg *AttachConfig) <-chan error {
          var group errgroup.Group
      
          // Connect stdin of container to the attach stdin stream.
          if cfg.Stdin != nil {
      Severity: Major
      Found in container/stream/attach.go - About 2 hrs to fix

        EndpointRecord has 24 methods (exceeds 20 allowed). Consider refactoring.
        Open

        type EndpointRecord struct {
            // Name of the container
            Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
            // Service name of the service to which this endpoint belongs.
            ServiceName string `protobuf:"bytes,2,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty"`
        Severity: Minor
        Found in libnetwork/agent.pb.go - About 2 hrs to fix

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

          func (sr *swarmRouter) createSecret(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
              var secret types.SecretSpec
              if err := httputils.ReadJSON(r, &secret); err != nil {
                  return err
              }
          Severity: Major
          Found in api/server/router/swarm/cluster_routes.go and 1 other location - About 2 hrs to fix
          api/server/router/swarm/cluster_routes.go on lines 506..525

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

          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 (sr *swarmRouter) createConfig(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
              var config types.ConfigSpec
              if err := httputils.ReadJSON(r, &config); err != nil {
                  return err
              }
          Severity: Major
          Found in api/server/router/swarm/cluster_routes.go and 1 other location - About 2 hrs to fix
          api/server/router/swarm/cluster_routes.go on lines 435..453

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

          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 IPTable.ProgramChain has 91 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (iptable IPTable) ProgramChain(c *ChainInfo, bridgeName string, hairpinMode, enable bool) error {
              if c.Name == "" {
                  return errors.New("could not program chain, missing chain name")
              }
          
          
          Severity: Major
          Found in libnetwork/iptables/iptables.go - About 2 hrs to fix

            Method Manager.CreateFromContext has 90 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (pm *Manager) CreateFromContext(ctx context.Context, tarCtx io.ReadCloser, options *types.PluginCreateOptions) (err error) {
                pm.muGC.RLock()
                defer pm.muGC.RUnlock()
            
                ref, err := reference.ParseNormalizedNamed(options.RepoName)
            Severity: Major
            Found in plugin/backend_linux.go - About 2 hrs to fix
              Severity
              Category
              Status
              Source
              Language