dotcloud/docker

View on GitHub
libcontainerd/remote/client.go

Summary

Maintainability
D
2 days
Test Coverage

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

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

    func (c *container) createIO(fifos *cio.FIFOSet, stdinCloseSync chan containerd.Process, attachStdio libcontainerdtypes.StdioCallback) (cio.IO, error) {
        var (
            io  *cio.DirectIO
            err error
        )
    Severity: Minor
    Found in libcontainerd/remote/client.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 client.processEventStream has 89 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (c *client) processEventStream(ctx context.Context, ns string) {
        // Create a new context specifically for this subscription.
        // The context must be cancelled to cancel the subscription.
        // In cases where we have to restart event stream processing,
        //   we'll need the original context b/c this one will be cancelled
    Severity: Major
    Found in libcontainerd/remote/client.go - About 2 hrs to fix

      Method container.NewTask has 77 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (c *container) NewTask(ctx context.Context, checkpointDir string, withStdin bool, attachStdio libcontainerdtypes.StdioCallback) (libcontainerdtypes.Task, error) {
          var (
              checkpoint     *types.Descriptor
              t              containerd.Task
              rio            cio.IO
      Severity: Major
      Found in libcontainerd/remote/client.go - About 2 hrs to fix

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

        func (c *client) processEventStream(ctx context.Context, ns string) {
            // Create a new context specifically for this subscription.
            // The context must be cancelled to cancel the subscription.
            // In cases where we have to restart event stream processing,
            //   we'll need the original context b/c this one will be cancelled
        Severity: Minor
        Found in libcontainerd/remote/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

        Method container.createIO has 52 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (c *container) createIO(fifos *cio.FIFOSet, stdinCloseSync chan containerd.Process, attachStdio libcontainerdtypes.StdioCallback) (cio.IO, error) {
            var (
                io  *cio.DirectIO
                err error
            )
        Severity: Minor
        Found in libcontainerd/remote/client.go - About 1 hr to fix

          Method container.NewTask has 9 return statements (exceeds 4 allowed).
          Open

          func (c *container) NewTask(ctx context.Context, checkpointDir string, withStdin bool, attachStdio libcontainerdtypes.StdioCallback) (libcontainerdtypes.Task, error) {
              var (
                  checkpoint     *types.Descriptor
                  t              containerd.Task
                  rio            cio.IO
          Severity: Major
          Found in libcontainerd/remote/client.go - About 55 mins to fix

            Method task.CreateCheckpoint has 7 return statements (exceeds 4 allowed).
            Open

            func (t *task) CreateCheckpoint(ctx context.Context, checkpointDir string, exit bool) error {
                img, err := t.Task.Checkpoint(ctx, t.ctr.getCheckpointOptions(exit))
                if err != nil {
                    return wrapError(err)
                }
            Severity: Major
            Found in libcontainerd/remote/client.go - About 45 mins to fix

              Method client.NewContainer has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func (c *client) NewContainer(ctx context.Context, id string, ociSpec *specs.Spec, shim string, runtimeOptions interface{}, opts ...containerd.NewContainerOpts) (libcontainerdtypes.Container, error) {
              Severity: Minor
              Found in libcontainerd/remote/client.go - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if c.waitServe(ctx) {
                                        go c.processEventStream(ctx, ns)
                                        return
                                    }
                Severity: Major
                Found in libcontainerd/remote/client.go - About 45 mins to fix

                  Method task.Exec has 6 return statements (exceeds 4 allowed).
                  Open

                  func (t *task) Exec(ctx context.Context, processID string, spec *specs.Process, withStdin bool, attachStdio libcontainerdtypes.StdioCallback) (libcontainerdtypes.Process, error) {
                      var (
                          p              containerd.Process
                          rio            cio.IO
                          stdinCloseSync = make(chan containerd.Process, 1)
                  Severity: Major
                  Found in libcontainerd/remote/client.go - About 40 mins to fix

                    Method task.Exec has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    func (t *task) Exec(ctx context.Context, processID string, spec *specs.Process, withStdin bool, attachStdio libcontainerdtypes.StdioCallback) (libcontainerdtypes.Process, error) {
                    Severity: Minor
                    Found in libcontainerd/remote/client.go - About 35 mins to fix

                      Method container.createIO has 5 return statements (exceeds 4 allowed).
                      Open

                      func (c *container) createIO(fifos *cio.FIFOSet, stdinCloseSync chan containerd.Process, attachStdio libcontainerdtypes.StdioCallback) (cio.IO, error) {
                          var (
                              io  *cio.DirectIO
                              err error
                          )
                      Severity: Major
                      Found in libcontainerd/remote/client.go - About 35 mins to fix

                        Method container.NewTask has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func (c *container) NewTask(ctx context.Context, checkpointDir string, withStdin bool, attachStdio libcontainerdtypes.StdioCallback) (libcontainerdtypes.Task, error) {
                            var (
                                checkpoint     *types.Descriptor
                                t              containerd.Task
                                rio            cio.IO
                        Severity: Minor
                        Found in libcontainerd/remote/client.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

                        There are no issues that match your filters.

                        Category
                        Status