dotcloud/docker

View on GitHub

Showing 1,904 of 1,904 total issues

Method ImageService.imageSummary has 13 return statements (exceeds 4 allowed).
Open

func (i *ImageService) imageSummary(ctx context.Context, img images.Image, platformMatcher platforms.MatchComparer,
    opts imagetypes.ListOptions, tagsByDigest map[digest.Digest][]string,
) (_ *imagetypes.Summary, allChainIDs []digest.Digest, _ error) {
    var manifestSummaries []imagetypes.ManifestSummary

Severity: Major
Found in daemon/containerd/image_list.go - About 1 hr to fix

    Function kernelSupportsRecursivelyReadOnly has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
    Open

    func kernelSupportsRecursivelyReadOnly() error {
        fn := func() error {
            tmpMnt, err := os.MkdirTemp("", "moby-detect-rro")
            if err != nil {
                return fmt.Errorf("failed to create a temp directory: %w", err)
    Severity: Minor
    Found in daemon/daemon_linux.go - About 1 hr 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.GetImageAndReleasableLayer has 13 return statements (exceeds 4 allowed).
    Open

    func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error) {
        if refOrID == "" { // FROM scratch
            if runtime.GOOS == "windows" {
                return nil, nil, fmt.Errorf(`"FROM scratch" is not supported on Windows`)
            }
    Severity: Major
    Found in daemon/containerd/image_builder.go - About 1 hr to fix

      Function ffjsonWriteJSONBytesAsString has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
      Open

      func ffjsonWriteJSONBytesAsString(buf *bytes.Buffer, s []byte) {
          const hex = "0123456789abcdef"
      
          buf.WriteByte('"')
          start := 0
      Severity: Minor
      Found in daemon/logger/jsonfilelog/jsonlog/jsonlogbytes.go - About 1 hr 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 buildIPAMResources has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
      Open

      func buildIPAMResources(nw *libnetwork.Network) networktypes.IPAM {
          var ipamConfig []networktypes.IPAMConfig
      
          ipamDriver, ipamOptions, ipv4Conf, ipv6Conf := nw.IpamConfig()
      
      
      Severity: Minor
      Found in daemon/network.go - About 1 hr 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.containerExtractToDir has 13 return statements (exceeds 4 allowed).
      Open

      func (daemon *Daemon) containerExtractToDir(container *container.Container, path string, copyUIDGID, noOverwriteDirNonDir bool, content io.Reader) (err error) {
          container.Lock()
          defer container.Unlock()
      
          // Make sure an online file-system operation is permitted.
      Severity: Major
      Found in daemon/archive_windows.go - About 1 hr to fix

        Method Daemon.fillRootlessVersion has 13 return statements (exceeds 4 allowed).
        Open

        func (daemon *Daemon) fillRootlessVersion(ctx context.Context, v *types.Version) error {
            if !rootless.RunningWithRootlessKit() {
                return nil
            }
            rlc, err := getRootlessKitClient()
        Severity: Major
        Found in daemon/info_unix.go - About 1 hr to fix

          Method Client.callWithRetry has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
          Open

          func (c *Client) callWithRetry(serviceMethod string, data io.Reader, retry bool, reqOpts ...func(*RequestOpts)) (io.ReadCloser, error) {
              var retries int
              start := time.Now()
          
              var opts RequestOpts
          Severity: Minor
          Found in pkg/plugins/client.go - About 1 hr 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 (p *puller) pullSchema2(ctx context.Context, ref reference.Named, mfst *schema2.DeserializedManifest, platform *ocispec.Platform) (id digest.Digest, manifestDigest digest.Digest, err error) {
              manifestDigest, err = schema2ManifestDigest(ref, mfst)
              if err != nil {
                  return "", "", err
              }
          Severity: Major
          Found in distribution/pull_v2.go and 1 other location - About 1 hr to fix
          distribution/pull_v2.go on lines 797..804

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

          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 m.VolumeOptions != nil {
                      mount.VolumeOptions = &swarmapi.Mount_VolumeOptions{
                          NoCopy:  m.VolumeOptions.NoCopy,
                          Labels:  m.VolumeOptions.Labels,
                          Subpath: m.VolumeOptions.Subpath,
          Severity: Major
          Found in daemon/cluster/convert/container.go and 1 other location - About 1 hr to fix
          daemon/cluster/convert/container.go on lines 122..134

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

          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 (s *containerRouter) postContainersPause(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
              if err := httputils.ParseForm(r); err != nil {
                  return err
              }
          
          
          Severity: Major
          Found in api/server/router/container/container_routes.go and 1 other location - About 1 hr to fix
          api/server/router/container/container_routes.go on lines 311..323

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

          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 (s *containerRouter) postContainersUnpause(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
              if err := httputils.ParseForm(r); err != nil {
                  return err
              }
          
          
          Severity: Major
          Found in api/server/router/container/container_routes.go and 1 other location - About 1 hr to fix
          api/server/router/container/container_routes.go on lines 297..309

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

          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 (pr *pluginRouter) removePlugin(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
              if err := httputils.ParseForm(r); err != nil {
                  return err
              }
          
          
          Severity: Major
          Found in api/server/router/plugin/plugin_routes.go and 1 other location - About 1 hr to fix
          api/server/router/plugin/plugin_routes.go on lines 216..227

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

          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 m.VolumeOptions != nil {
                      mount.VolumeOptions = &mounttypes.VolumeOptions{
                          NoCopy:  m.VolumeOptions.NoCopy,
                          Labels:  m.VolumeOptions.Labels,
                          Subpath: m.VolumeOptions.Subpath,
          Severity: Major
          Found in daemon/cluster/convert/container.go and 1 other location - About 1 hr to fix
          daemon/cluster/convert/container.go on lines 411..423

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

          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 (p *puller) pullOCI(ctx context.Context, ref reference.Named, mfst *ocischema.DeserializedManifest, platform *ocispec.Platform) (id digest.Digest, manifestDigest digest.Digest, err error) {
              manifestDigest, err = schema2ManifestDigest(ref, mfst)
              if err != nil {
                  return "", "", err
              }
          Severity: Major
          Found in distribution/pull_v2.go and 1 other location - About 1 hr to fix
          distribution/pull_v2.go on lines 788..795

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

          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 (pr *pluginRouter) disablePlugin(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
              if err := httputils.ParseForm(r); err != nil {
                  return err
              }
          
          
          Severity: Major
          Found in api/server/router/plugin/plugin_routes.go and 1 other location - About 1 hr to fix
          api/server/router/plugin/plugin_routes.go on lines 229..239

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

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

          func pullEndpoints(ctx context.Context, registryService RegistryResolver, ref reference.Named,
              f func(context.Context, registry.RepositoryInfo, registry.APIEndpoint) error,
          ) (*registry.RepositoryInfo, error) {
              // Resolve the Repository name from fqn to RepositoryInfo
              repoInfo, err := registryService.ResolveRepository(ref)
          Severity: Minor
          Found in distribution/pull.go - About 1 hr to fix

            Function Client has 56 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func Client(args []string) {
                log.G(context.TODO()).Infof("[CLIENT] Starting with arguments %v", args)
                command := args[0]
            
                if len(args) < cmdArgCheck[command] {
            Severity: Minor
            Found in libnetwork/cmd/networkdb-test/dbclient/ndbClient.go - About 1 hr to fix

              Method Namespace.AddNeighbor has 56 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (n *Namespace) AddNeighbor(dstIP net.IP, dstMac net.HardwareAddr, force bool, options ...NeighOption) error {
                  var (
                      iface                  netlink.Link
                      err                    error
                      neighborAlreadyPresent bool
              Severity: Minor
              Found in libnetwork/osl/neigh_linux.go - About 1 hr to fix

                Method VolumeStore.restore has 56 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (s *VolumeStore) restore() {
                    var ls []volumeMetadata
                    s.db.View(func(tx *bolt.Tx) error {
                        ls = listMeta(tx)
                        return nil
                Severity: Minor
                Found in volume/service/restore.go - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language