dotcloud/docker

View on GitHub

Showing 1,885 of 1,885 total issues

Method Cluster.ServiceLogs has 112 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (c *Cluster) ServiceLogs(ctx context.Context, selector *backend.LogSelector, config *container.LogsOptions) (<-chan *backend.LogMessage, error) {
    c.mu.RLock()
    defer c.mu.RUnlock()

    state := c.currentNodeState()
Severity: Major
Found in daemon/cluster/services.go - About 3 hrs to fix

    Function DirCopy has 112 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func DirCopy(srcDir, dstDir string, copyMode Mode, copyOpaqueXattrs bool) error {
        copyWithFileRange := true
        copyWithFileClone := true
    
        // This is a map of source file inodes to dst file paths
    Severity: Major
    Found in daemon/graphdriver/copy/copy.go - About 3 hrs to fix

      Method driver.CreateNetwork has 111 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error {
          if _, err := d.getNetwork(id); err == nil {
              return types.ForbiddenErrorf("network %s exists", id)
          }
      
      
      Severity: Major
      Found in libnetwork/drivers/windows/windows.go - About 3 hrs to fix

        Function WithNamespaces has 111 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func WithNamespaces(daemon *Daemon, c *container.Container) coci.SpecOpts {
            return func(ctx context.Context, _ coci.Client, _ *containers.Container, s *coci.Spec) error {
                userNS := false
                // user
                if c.HostConfig.UsernsMode.IsPrivate() {
        Severity: Major
        Found in daemon/oci_linux.go - About 3 hrs to fix

          Function compare has 39 return statements (exceeds 4 allowed).
          Open

          func compare(a, b *container.Config) bool {
              if a == nil || b == nil {
                  return false
              }
          
          
          Severity: Major
          Found in image/cache/compare.go - About 3 hrs to fix

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

            func (na *cnmNetworkAllocator) AllocateService(s *api.Service) (err error) {
                defer func() {
                    if err != nil {
                        na.DeallocateService(s)
                    }
            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

            Method client.newStdioPipes has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring.
            Open

            func (c *client) newStdioPipes(fifos *cio.FIFOSet) (_ *stdioPipes, err error) {
                p := &stdioPipes{}
                if fifos.Stdin != "" {
                    c.logger.WithField("stdin", fifos.Stdin).Debug("listen")
                    l, err := winio.ListenPipe(fifos.Stdin, nil)
            Severity: Minor
            Found in libcontainerd/remote/client_io_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

            Method controller.Start has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring.
            Open

            func (r *controller) Start(ctx context.Context) error {
                if err := r.checkClosed(); err != nil {
                    return err
                }
            
            
            Severity: Minor
            Found in daemon/cluster/executor/container/controller.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

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

            func (s *containerRouter) postContainersRestart(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 3 hrs to fix
            api/server/router/container/container_routes.go on lines 227..253

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

            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) postContainersStop(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 3 hrs to fix
            api/server/router/container/container_routes.go on lines 269..295

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

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

            func (i *ImageService) ExportImage(ctx context.Context, names []string, outStream io.Writer) error {
                platform := matchAllWithPreference(platforms.Default())
                opts := []archive.ExportOpt{
                    archive.WithSkipNonDistributableBlobs(),
            
            
            Severity: Major
            Found in daemon/containerd/image_exporter.go - About 3 hrs to fix

              File splunk.go has 558 lines of code (exceeds 500 allowed). Consider refactoring.
              Open

              // Package splunk provides the log driver for forwarding server logs to
              // Splunk HTTP Event Collector endpoint.
              package splunk // import "github.com/docker/docker/daemon/logger/splunk"
              
              import (
              Severity: Minor
              Found in daemon/logger/splunk/splunk.go - About 3 hrs to fix

                Method ImageService.ImageDelete has 109 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force, prune bool) (response []imagetypes.DeleteResponse, retErr error) {
                    start := time.Now()
                    defer func() {
                        if retErr == nil {
                            dimages.ImageActions.WithValues("delete").UpdateSince(start)
                Severity: Major
                Found in daemon/containerd/image_delete.go - About 3 hrs to fix

                  Sandbox has 28 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (sb *Sandbox) processOptions(options ...SandboxOption) {
                      for _, opt := range options {
                          if opt != nil {
                              opt(sb)
                          }
                  Severity: Minor
                  Found in libnetwork/sandbox.go - About 3 hrs to fix

                    File push_v2.go has 555 lines of code (exceeds 500 allowed). Consider refactoring.
                    Open

                    package distribution // import "github.com/docker/docker/distribution"
                    
                    import (
                        "context"
                        "fmt"
                    Severity: Minor
                    Found in distribution/push_v2.go - About 3 hrs to fix

                      Method ImageService.ImportImage has 108 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (i *ImageService) ImportImage(ctx context.Context, ref reference.Named, platform *ocispec.Platform, msg string, layerReader io.Reader, changes []string) (image.ID, error) {
                          refString := ""
                          if ref != nil {
                              refString = ref.String()
                          }
                      Severity: Major
                      Found in daemon/containerd/image_import.go - About 3 hrs to fix

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

                        package client // import "github.com/docker/docker/client"
                        
                        import (
                            "context"
                            "encoding/json"
                        Severity: Major
                        Found in client/config_list.go and 1 other location - About 3 hrs to fix
                        client/secret_list.go on lines 1..38

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

                        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"
                            "encoding/json"
                        Severity: Major
                        Found in client/secret_list.go and 1 other location - About 3 hrs to fix
                        client/config_list.go on lines 1..38

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

                        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 Sandbox.populateNetworkResources has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func (sb *Sandbox) populateNetworkResources(ctx context.Context, ep *Endpoint) error {
                            ctx, span := otel.Tracer("").Start(ctx, "libnetwork.Sandbox.populateNetworkResources", trace.WithAttributes(
                                attribute.String("endpoint.Name", ep.Name())))
                            defer span.End()
                        
                        
                        Severity: Minor
                        Found in libnetwork/sandbox_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 Go has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func Go(flags int, setupfn func() error, fn func()) error {
                            started := make(chan error)
                        
                            maskedFlags := flags
                            for f := range reversibleSetnsFlags {
                        Severity: Minor
                        Found in internal/unshare/unshare_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

                        Severity
                        Category
                        Status
                        Source
                        Language