dotcloud/docker

View on GitHub

Showing 1,885 of 1,885 total issues

Method Daemon.ProcessEvent has a Cognitive Complexity of 50 (exceeds 20 allowed). Consider refactoring.
Open

func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei libcontainerdtypes.EventInfo) error {
    c, err := daemon.GetContainer(id)
    if err != nil {
        return errors.Wrapf(err, "could not find container %s", id)
    }
Severity: Minor
Found in daemon/monitor.go - About 5 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

Controller has 39 methods (exceeds 20 allowed). Consider refactoring.
Open

type Controller struct {
    id               string
    drvRegistry      drvregistry.Networks
    ipamRegistry     drvregistry.IPAMs
    sandboxes        map[string]*Sandbox
Severity: Minor
Found in libnetwork/controller.go - About 5 hrs to fix

    Method containerRouter.postContainersCreate has 154 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (s *containerRouter) postContainersCreate(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
        if err := httputils.ParseForm(r); err != nil {
            return err
        }
        if err := httputils.CheckForJSON(r); err != nil {
    Severity: Major
    Found in api/server/router/container/container_routes.go - About 5 hrs to fix

      File layer_store.go has 630 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      package layer // import "github.com/docker/docker/layer"
      
      import (
          "context"
          "errors"
      Severity: Minor
      Found in layer/layer_store.go - About 5 hrs to fix

        Function withMounts has 152 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func withMounts(daemon *Daemon, daemonCfg *configStore, c *container.Container, ms []container.Mount) coci.SpecOpts {
            return func(ctx context.Context, _ coci.Client, _ *containers.Container, s *coci.Spec) (err error) {
                sort.Sort(mounts(ms))
        
                mounts := ms
        Severity: Major
        Found in daemon/oci_linux.go - About 5 hrs to fix

          File client.go has 628 lines of code (exceeds 500 allowed). Consider refactoring.
          Open

          package remote // import "github.com/docker/docker/libcontainerd/remote"
          
          import (
              "context"
              "encoding/json"
          Severity: Minor
          Found in libcontainerd/remote/client.go - About 5 hrs to fix

            Endpoint has 38 methods (exceeds 20 allowed). Consider refactoring.
            Open

            type Endpoint struct {
                name         string
                id           string
                network      *Network
                iface        *EndpointInterface
            Severity: Minor
            Found in libnetwork/endpoint.go - About 5 hrs to fix

              Method NetworkEntry.Unmarshal has 150 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

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

                Method NetworkEvent.Unmarshal has 149 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

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

                  Method puller.pullTag has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (p *puller) pullTag(ctx context.Context, ref reference.Named, platform *ocispec.Platform) (tagUpdated bool, err error) {
                      var (
                          tagOrDigest string // Used for logging/progress only
                          dgst        digest.Digest
                          mt          string
                  Severity: Minor
                  Found in distribution/pull_v2.go - About 4 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 layerDescriptor.Download has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (ld *layerDescriptor) Download(ctx context.Context, progressOutput progress.Output) (io.ReadCloser, int64, error) {
                      log.G(ctx).Debugf("pulling blob %q", ld.digest)
                  
                      var (
                          err    error
                  Severity: Minor
                  Found in distribution/pull_v2.go - About 4 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 imageRouter.postImagesCreate has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (ir *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
                      if err := httputils.ParseForm(r); err != nil {
                          return err
                      }
                  
                  
                  Severity: Minor
                  Found in api/server/router/image/image_routes.go - About 4 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 Daemon.ContainerLogs has a Cognitive Complexity of 48 (exceeds 20 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: Minor
                  Found in daemon/logs.go - About 4 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 containerToGRPC has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func containerToGRPC(c *types.ContainerSpec) (*swarmapi.ContainerSpec, error) {
                      containerSpec := &swarmapi.ContainerSpec{
                          Image:          c.Image,
                          Labels:         c.Labels,
                          Command:        c.Command,
                  Severity: Minor
                  Found in daemon/cluster/convert/container.go - About 4 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 Daemon.findAndAttachNetwork has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (daemon *Daemon) findAndAttachNetwork(ctr *container.Container, idOrName string, epConfig *networktypes.EndpointSettings) (*libnetwork.Network, *networktypes.NetworkingConfig, error) {
                      id := getNetworkID(idOrName, epConfig)
                  
                      n, err := daemon.FindNetwork(id)
                      if err != nil {
                  Severity: Minor
                  Found in daemon/container_operations.go - About 4 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.createWindows has 147 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (c *client) createWindows(id string, spec *specs.Spec, runtimeOptions interface{}) (*container, error) {
                      logger := c.logger.WithField("container", id)
                      configuration := &hcsshim.ContainerConfig{
                          SystemType:              "Container",
                          Name:                    id,
                  Severity: Major
                  Found in libcontainerd/local/local_windows.go - About 4 hrs to fix

                    Method Daemon.ContainerExecStart has 146 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (daemon *Daemon) ContainerExecStart(ctx context.Context, name string, options backend.ExecStartConfig) (err error) {
                        var (
                            cStdin           io.ReadCloser
                            cStdout, cStderr io.Writer
                        )
                    Severity: Major
                    Found in daemon/exec.go - About 4 hrs to fix

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

                      func (nDB *NetworkDB) dbLeaveNetwork(w http.ResponseWriter, r *http.Request) {
                          _ = r.ParseForm()
                          diagnostic.DebugHTTPForm(r)
                          _, json := diagnostic.ParseHTTPFormOptions(r)
                      
                      
                      Severity: Major
                      Found in libnetwork/networkdb/networkdbdiagnostic.go and 1 other location - About 4 hrs to fix
                      libnetwork/networkdb/networkdbdiagnostic.go on lines 308..338

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

                      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 (nDB *NetworkDB) dbJoinNetwork(w http.ResponseWriter, r *http.Request) {
                          _ = r.ParseForm()
                          diagnostic.DebugHTTPForm(r)
                          _, json := diagnostic.ParseHTTPFormOptions(r)
                      
                      
                      Severity: Major
                      Found in libnetwork/networkdb/networkdbdiagnostic.go and 1 other location - About 4 hrs to fix
                      libnetwork/networkdb/networkdbdiagnostic.go on lines 340..370

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

                      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 Controller.reservePools has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (c *Controller) reservePools() {
                          networks, err := c.getNetworks()
                          if err != nil {
                              log.G(context.TODO()).Warnf("Could not retrieve networks from local store during ipam allocation for existing networks: %v", err)
                              return
                      Severity: Minor
                      Found in libnetwork/controller.go - About 4 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