dotcloud/docker

View on GitHub
daemon/cluster/executor/container/adapter.go

Summary

Maintainability
B
6 hrs
Test Coverage

Method containerAdapter.pullImage has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
Open

func (c *containerAdapter) pullImage(ctx context.Context) error {
    spec := c.container.spec()

    // Skip pulling if the image is referenced by image ID.
    if _, err := digest.Parse(spec.Image); err == nil {
Severity: Minor
Found in daemon/cluster/executor/container/adapter.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 containerAdapter.pullImage has 69 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (c *containerAdapter) pullImage(ctx context.Context) error {
    spec := c.container.spec()

    // Skip pulling if the image is referenced by image ID.
    if _, err := digest.Parse(spec.Image); err == nil {
Severity: Minor
Found in daemon/cluster/executor/container/adapter.go - About 1 hr to fix

    Function newContainerAdapter has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    func newContainerAdapter(b executorpkg.Backend, i executorpkg.ImageBackend, v executorpkg.VolumeBackend, task *api.Task, node *api.NodeDescription, dependencies exec.DependencyGetter) (*containerAdapter, error) {
    Severity: Minor
    Found in daemon/cluster/executor/container/adapter.go - About 45 mins to fix

      Method containerAdapter.pullImage has 6 return statements (exceeds 4 allowed).
      Open

      func (c *containerAdapter) pullImage(ctx context.Context) error {
          spec := c.container.spec()
      
          // Skip pulling if the image is referenced by image ID.
          if _, err := digest.Parse(spec.Image); err == nil {
      Severity: Major
      Found in daemon/cluster/executor/container/adapter.go - About 40 mins to fix

        Method containerAdapter.create has 6 return statements (exceeds 4 allowed).
        Open

        func (c *containerAdapter) create(ctx context.Context) error {
            hostConfig := c.container.hostConfig(c.dependencies.Volumes())
            netConfig := c.container.createNetworkingConfig(c.backend)
        
            // We need to make sure no empty string or "default" NetworkMode is
        Severity: Major
        Found in daemon/cluster/executor/container/adapter.go - About 40 mins to fix

          There are no issues that match your filters.

          Category
          Status