dotcloud/docker

View on GitHub

Showing 1,904 of 1,904 total issues

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

package client // import "github.com/docker/docker/client"

import "context"

// ConfigRemove removes a config.
Severity: Minor
Found in client/config_remove.go and 1 other location - About 35 mins to fix
client/secret_remove.go on lines 1..13

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

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

    if c.HostConfig.PortBindings != nil {
        for p, b := range c.HostConfig.PortBindings {
            bindings[p] = []nat.PortBinding{}
            for _, bb := range b {
                bindings[p] = append(bindings[p], nat.PortBinding{
Severity: Minor
Found in daemon/network.go and 1 other location - About 35 mins to fix
daemon/container_operations.go on lines 101..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 106.

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

package client // import "github.com/docker/docker/client"

import "context"

// SecretRemove removes a secret.
Severity: Minor
Found in client/secret_remove.go and 1 other location - About 35 mins to fix
client/config_remove.go on lines 1..13

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

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

    if create.EnableIPv4 != nil {
        enableIPv4 = *create.EnableIPv4
    } else if v, ok := networkOptions[netlabel.EnableIPv4]; ok {
        var err error
        if enableIPv4, err = strconv.ParseBool(v); err != nil {
Severity: Minor
Found in daemon/network.go and 1 other location - About 35 mins to fix
daemon/network.go on lines 335..342

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

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 ParseLink has 5 return statements (exceeds 4 allowed).
Open

func ParseLink(val string) (string, string, error) {
    if val == "" {
        return "", "", fmt.Errorf("empty string specified for links")
    }
    arr := strings.Split(val, ":")
Severity: Major
Found in opts/opts.go - About 35 mins to fix

    Method tarexporter.loadLayer has 5 return statements (exceeds 4 allowed).
    Open

    func (l *tarexporter) loadLayer(ctx context.Context, filename string, rootFS image.RootFS, id string, foreignSrc distribution.Descriptor, progressOutput progress.Output) (_ layer.Layer, outErr error) {
        ctx, span := tracing.StartSpan(ctx, "loadLayer")
        span.SetAttributes(tracing.Attribute("image.id", id))
        defer span.End()
        defer func() {
    Severity: Major
    Found in image/tarexport/load.go - About 35 mins to fix

      Method RuntimeOpt.Set has 5 return statements (exceeds 4 allowed).
      Open

      func (o *RuntimeOpt) Set(val string) error {
          k, v, ok := strings.Cut(val, "=")
          if !ok {
              return fmt.Errorf("invalid runtime argument: %s", val)
          }
      Severity: Major
      Found in opts/runtime.go - About 35 mins to fix

        Method PoolsOpt.Set has 5 return statements (exceeds 4 allowed).
        Open

        func (p *PoolsOpt) Set(value string) error {
            csvReader := csv.NewReader(strings.NewReader(value))
            fields, err := csvReader.Read()
            if err != nil {
                return err
        Severity: Major
        Found in opts/address_pools.go - About 35 mins to fix

          Method puller.pullSchema2Config has 5 return statements (exceeds 4 allowed).
          Open

          func (p *puller) pullSchema2Config(ctx context.Context, dgst digest.Digest) (configJSON []byte, err error) {
              blobs := p.repo.Blobs(ctx)
              err = retry(ctx, defaultMaxSchemaPullAttempts, defaultSchemaPullBackoff, func(ctx context.Context) (err error) {
                  configJSON, err = blobs.Get(ctx, dgst)
                  return err
          Severity: Major
          Found in distribution/pull_v2.go - About 35 mins to fix

            Function tempMountPoint has 5 return statements (exceeds 4 allowed).
            Open

            func tempMountPoint(sourceFd int) (string, error) {
                var stat unix.Stat_t
                err := unix_noeintr.Fstat(sourceFd, &stat)
                if err != nil {
                    return "", errors.Wrap(err, "failed to Fstat mount source fd")
            Severity: Major
            Found in internal/safepath/join_linux.go - About 35 mins to fix

              Method RestartManager.ShouldRestart has 5 return statements (exceeds 4 allowed).
              Open

              func (rm *RestartManager) ShouldRestart(exitCode uint32, hasBeenManuallyStopped bool, executionDuration time.Duration) (bool, chan error, error) {
                  if rm.policy.IsNone() {
                      return false, nil, nil
                  }
                  rm.Lock()
              Severity: Major
              Found in restartmanager/restartmanager.go - About 35 mins to fix

                Function toRootless has 5 return statements (exceeds 4 allowed).
                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: Major
                Found in internal/rootless/specconv/specconv_linux.go - About 35 mins to fix

                  Function atomicRemoveAll has 5 return statements (exceeds 4 allowed).
                  Open

                  func atomicRemoveAll(dir string) error {
                      renamed := dir + "-removing"
                  
                      err := os.Rename(dir, renamed)
                      switch {
                  Severity: Major
                  Found in plugin/backend_linux.go - About 35 mins to fix

                    Function detectManifestBlobMediaType has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func detectManifestBlobMediaType(dt []byte) (string, error) {
                        var mfst struct {
                            MediaType string          `json:"mediaType"`
                            Manifests json.RawMessage `json:"manifests"` // oci index, manifest list
                            Config    json.RawMessage `json:"config"`    // schema2 Manifest
                    Severity: Minor
                    Found in distribution/manifest.go - About 35 mins 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 Join has 5 return statements (exceeds 4 allowed).
                    Open

                    func Join(_ context.Context, path, subpath string) (*SafePath, error) {
                        base, subpart, err := evaluatePath(path, subpath)
                        if err != nil {
                            return nil, err
                        }
                    Severity: Major
                    Found in internal/safepath/join_linux.go - About 35 mins to fix

                      Method Manager.fetch has 5 return statements (exceeds 4 allowed).
                      Open

                      func (pm *Manager) fetch(ctx context.Context, ref reference.Named, auth *registry.AuthConfig, out progress.Output, metaHeader http.Header, handlers ...images.Handler) (err error) {
                          // We need to make sure we have a domain on the reference
                          withDomain, err := reference.ParseNormalizedNamed(ref.String())
                          if err != nil {
                              return errors.Wrap(err, "error parsing plugin image reference")
                      Severity: Major
                      Found in plugin/fetch_linux.go - About 35 mins to fix

                        Method LayerDownloadManager.Download has 5 return statements (exceeds 4 allowed).
                        Open

                        func (ldm *LayerDownloadManager) Download(ctx context.Context, initialRootFS image.RootFS, layers []DownloadDescriptor, progressOutput progress.Output) (image.RootFS, func(), error) {
                            var (
                                topLayer       layer.Layer
                                topDownload    *downloadTransfer
                                watcher        *watcher
                        Severity: Major
                        Found in distribution/xfer/download.go - About 35 mins to fix

                          Function kubernetesSafeOpen has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func kubernetesSafeOpen(base, subpath string) (int, error) {
                              // syscall.Openat flags used to traverse directories not following symlinks
                              const nofollowFlags = unix.O_RDONLY | unix.O_NOFOLLOW
                              // flags for getting file descriptor without following the symlink
                              const openFDFlags = unix.O_NOFOLLOW | unix.O_PATH
                          Severity: Minor
                          Found in internal/safepath/k8s_safeopen_linux.go - About 35 mins 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 schema2ManifestDigest has 5 return statements (exceeds 4 allowed).
                          Open

                          func schema2ManifestDigest(ref reference.Named, mfst distribution.Manifest) (digest.Digest, error) {
                              _, canonical, err := mfst.Payload()
                              if err != nil {
                                  return "", err
                              }
                          Severity: Major
                          Found in distribution/pull_v2.go - About 35 mins to fix

                            Function DevicesFromPath has 5 return statements (exceeds 4 allowed).
                            Open

                            func DevicesFromPath(pathOnHost, pathInContainer, cgroupPermissions string) (devs []specs.LinuxDevice, devPermissions []specs.LinuxDeviceCgroup, err error) {
                                resolvedPathOnHost := pathOnHost
                            
                                // check if it is a symbolic link
                                if src, e := os.Lstat(pathOnHost); e == nil && src.Mode()&os.ModeSymlink == os.ModeSymlink {
                            Severity: Major
                            Found in oci/devices_linux.go - About 35 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language