dotcloud/docker

View on GitHub
daemon/oci_windows.go

Summary

Maintainability
D
1 day
Test Coverage

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

func (daemon *Daemon) createSpec(ctx context.Context, daemonCfg *configStore, c *container.Container, mounts []container.Mount) (*specs.Spec, error) {
    img, err := daemon.imageService.GetImage(ctx, string(c.ImageID), backend.GetImageOpts{})
    if err != nil {
        return nil, err
    }
Severity: Minor
Found in daemon/oci_windows.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.createSpec has 105 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (daemon *Daemon) createSpec(ctx context.Context, daemonCfg *configStore, c *container.Container, mounts []container.Mount) (*specs.Spec, error) {
    img, err := daemon.imageService.GetImage(ctx, string(c.ImageID), backend.GetImageOpts{})
    if err != nil {
        return nil, err
    }
Severity: Major
Found in daemon/oci_windows.go - About 3 hrs to fix

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

    func (daemon *Daemon) setWindowsCredentialSpec(c *container.Container, s *specs.Spec) error {
        if c.HostConfig == nil || c.HostConfig.SecurityOpt == nil {
            return nil
        }
    
    
    Severity: Minor
    Found in daemon/oci_windows.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

    Function setResourcesInSpec has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
    Open

    func setResourcesInSpec(c *container.Container, s *specs.Spec, isHyperV bool) {
        // In s.Windows.Resources
        cpuShares := uint16(c.HostConfig.CPUShares)
        cpuMaximum := uint16(c.HostConfig.CPUPercent) * 100
        cpuCount := uint64(c.HostConfig.CPUCount)
    Severity: Minor
    Found in daemon/oci_windows.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 Daemon.setWindowsCredentialSpec has 9 return statements (exceeds 4 allowed).
    Open

    func (daemon *Daemon) setWindowsCredentialSpec(c *container.Container, s *specs.Spec) error {
        if c.HostConfig == nil || c.HostConfig.SecurityOpt == nil {
            return nil
        }
    
    
    Severity: Major
    Found in daemon/oci_windows.go - About 55 mins to fix

      Method Daemon.setupContainerDirs has 7 return statements (exceeds 4 allowed).
      Open

      func (daemon *Daemon) setupContainerDirs(c *container.Container) ([]container.Mount, error) {
          // Note, unlike Unix, we do NOT call into SetupWorkingDirectory as
          // this is done in VMCompute. Further, we couldn't do it for Hyper-V
          // containers anyway.
          if err := daemon.setupSecretDir(c); err != nil {
      Severity: Major
      Found in daemon/oci_windows.go - About 45 mins to fix

        Method Daemon.createSpec has 7 return statements (exceeds 4 allowed).
        Open

        func (daemon *Daemon) createSpec(ctx context.Context, daemonCfg *configStore, c *container.Container, mounts []container.Mount) (*specs.Spec, error) {
            img, err := daemon.imageService.GetImage(ctx, string(c.ImageID), backend.GetImageOpts{})
            if err != nil {
                return nil, err
            }
        Severity: Major
        Found in daemon/oci_windows.go - About 45 mins to fix

          Method Daemon.createSpecWindowsFields has 5 return statements (exceeds 4 allowed).
          Open

          func (daemon *Daemon) createSpecWindowsFields(c *container.Container, s *specs.Spec, isHyperV bool) error {
              s.Hostname = c.FullHostname()
          
              if len(s.Process.Cwd) == 0 {
                  // We default to C:\ to workaround the oddity of the case that the
          Severity: Major
          Found in daemon/oci_windows.go - About 35 mins to fix

            There are no issues that match your filters.

            Category
            Status