dotcloud/docker

View on GitHub

Showing 1,885 of 1,885 total issues

Method ImageService.ImagesPrune has 102 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (i *ImageService) ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*imagetypes.PruneReport, error) {
    if !atomic.CompareAndSwapInt32(&i.pruneRunning, 0, 1) {
        return nil, errPruneRunning
    }
    defer atomic.StoreInt32(&i.pruneRunning, 0)
Severity: Major
Found in daemon/images/image_prune.go - About 3 hrs to fix

    Method Endpoint.UnmarshalJSON has 101 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (ep *Endpoint) UnmarshalJSON(b []byte) (err error) {
        ep.mu.Lock()
        defer ep.mu.Unlock()
    
        var epMap map[string]interface{}
    Severity: Major
    Found in libnetwork/endpoint.go - About 3 hrs to fix

      Method ImageService.pruneUnused has 101 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (i *ImageService) pruneUnused(ctx context.Context, filterFunc imageFilterFunc, danglingOnly bool) (*image.PruneReport, error) {
          report := image.PruneReport{}
      
          allImages, err := i.images.List(ctx)
          if err != nil {
      Severity: Major
      Found in daemon/containerd/image_prune.go - About 3 hrs to fix

        Method Daemon.ContainerLogs has 101 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (daemon *Daemon) ContainerLogs(ctx context.Context, containerName string, config *containertypes.LogsOptions) (messages <-chan *backend.LogMessage, isTTY bool, retErr error) {
            lg := log.G(ctx).WithFields(log.Fields{
                "module":    "daemon",
                "method":    "(*Daemon).ContainerLogs",
                "container": containerName,
        Severity: Major
        Found in daemon/logs.go - About 3 hrs to fix

          Method Copier.copySrc has 101 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (c *Copier) copySrc(name string, src io.Reader) {
              defer c.copyJobs.Done()
          
              bufSize := defaultBufSize
              if sizedLogger, ok := c.dst.(SizedLogger); ok {
          Severity: Major
          Found in daemon/logger/copier.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 (
                "bytes"
                "context"
            Severity: Major
            Found in client/node_inspect.go and 1 other location - About 3 hrs to fix
            client/task_inspect.go on lines 1..32

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

            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 (
                "bytes"
                "context"
            Severity: Major
            Found in client/task_inspect.go and 1 other location - About 3 hrs to fix
            client/node_inspect.go on lines 1..32

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

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

            func (m *GossipMessage) Unmarshal(dAtA []byte) error {
                l := len(dAtA)
                iNdEx := 0
                for iNdEx < l {
                    preIndex := iNdEx
            Severity: Major
            Found in libnetwork/networkdb/networkdb.pb.go - About 3 hrs to fix

              Method Controller.sandboxCleanup has 100 lines of code (exceeds 50 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: Major
              Found in libnetwork/sandbox_store.go - About 3 hrs to fix

                State has 26 methods (exceeds 20 allowed). Consider refactoring.
                Open

                type State struct {
                    sync.Mutex
                    // Note that `Running` and `Paused` are not mutually exclusive:
                    // When pausing a container (on Linux), the freezer cgroup is used to suspend
                    // all processes in the container. Freezing the process requires the process to
                Severity: Minor
                Found in container/state.go - About 3 hrs to fix

                  Method LogEntry.Unmarshal has 34 return statements (exceeds 4 allowed).
                  Open

                  func (m *LogEntry) Unmarshal(dAtA []byte) error {
                      l := len(dAtA)
                      iNdEx := 0
                      for iNdEx < l {
                          preIndex := iNdEx
                  Severity: Major
                  Found in api/types/plugins/logdriver/entry.pb.go - About 3 hrs to fix

                    Method ImageService.setupFilters has 100 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (i *ImageService) setupFilters(ctx context.Context, imageFilters filters.Args) (filterFunc imageFilterFunc, outErr error) {
                        var fltrs []imageFilterFunc
                        err := imageFilters.WalkValues("before", func(value string) error {
                            img, err := i.GetImage(ctx, value, backend.GetImageOpts{})
                            if err != nil {
                    Severity: Major
                    Found in daemon/containerd/image_list.go - About 3 hrs to fix

                      Method Cluster.UpdateService has 100 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (c *Cluster) UpdateService(serviceIDOrName string, version uint64, spec swarm.ServiceSpec, flags types.ServiceUpdateOptions, queryRegistry bool) (*swarm.ServiceUpdateResponse, error) {
                          var resp *swarm.ServiceUpdateResponse
                      
                          err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
                              err := c.populateNetworkID(ctx, state.controlClient, &spec)
                      Severity: Major
                      Found in daemon/cluster/services.go - About 3 hrs to fix

                        Method pusher.pushTag has 99 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (p *pusher) pushTag(ctx context.Context, ref reference.NamedTagged, id digest.Digest) error {
                            log.G(ctx).Debugf("Pushing repository: %s", reference.FamiliarString(ref))
                        
                            imgConfig, err := p.config.ImageStore.Get(ctx, id)
                            if err != nil {
                        Severity: Major
                        Found in distribution/push_v2.go - About 2 hrs to fix

                          Method driver.CreateEndpoint has 98 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (d *driver) CreateEndpoint(ctx context.Context, nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error {
                              var err error
                              if err = validateID(nid, eid); err != nil {
                                  return err
                              }
                          Severity: Major
                          Found in libnetwork/drivers/windows/overlay/ov_endpoint_windows.go - About 2 hrs to fix

                            Function newImageBuildOptions has 98 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func newImageBuildOptions(ctx context.Context, r *http.Request) (*types.ImageBuildOptions, error) {
                                options := &types.ImageBuildOptions{
                                    Version:        types.BuilderV1, // Builder V1 is the default, but can be overridden
                                    Dockerfile:     r.FormValue("dockerfile"),
                                    SuppressOutput: httputils.BoolValue(r, "q"),
                            Severity: Major
                            Found in api/server/router/build/build_routes.go - About 2 hrs to fix

                              Method LayerDownloadManager.Download has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
                              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: Minor
                              Found in distribution/xfer/download.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 Endpoint.sbLeave has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
                              Open

                              func (ep *Endpoint) sbLeave(ctx context.Context, sb *Sandbox, force bool) error {
                                  n, err := ep.getNetworkFromStore()
                                  if err != nil {
                                      return fmt.Errorf("failed to get network from store during leave: %v", err)
                                  }
                              Severity: Minor
                              Found in libnetwork/endpoint.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 BulkSyncMessage.Unmarshal has 33 return statements (exceeds 4 allowed).
                              Open

                              func (m *BulkSyncMessage) Unmarshal(dAtA []byte) error {
                                  l := len(dAtA)
                                  iNdEx := 0
                                  for iNdEx < l {
                                      preIndex := iNdEx
                              Severity: Major
                              Found in libnetwork/networkdb/networkdb.pb.go - About 2 hrs to fix

                                Method networkConfiguration.fromLabels has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
                                Open

                                func (c *networkConfiguration) fromLabels(labels map[string]string) error {
                                    var err error
                                    for label, value := range labels {
                                        switch label {
                                        case BridgeName:
                                Severity: Minor
                                Found in libnetwork/drivers/bridge/bridge_linux.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

                                Severity
                                Category
                                Status
                                Source
                                Language