dotcloud/docker

View on GitHub
daemon/cluster/convert/container.go

Summary

Maintainability
F
3 days
Test Coverage

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

Function containerToGRPC has 133 lines of code (exceeds 50 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: Major
Found in daemon/cluster/convert/container.go - About 4 hrs to fix

    Function containerSpecFromGRPC has 119 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func containerSpecFromGRPC(c *swarmapi.ContainerSpec) *types.ContainerSpec {
        if c == nil {
            return nil
        }
        containerSpec := &types.ContainerSpec{
    Severity: Major
    Found in daemon/cluster/convert/container.go - About 3 hrs to fix

      File container.go has 503 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      package convert // import "github.com/docker/docker/daemon/cluster/convert"
      
      import (
          "context"
          "encoding/json"
      Severity: Minor
      Found in daemon/cluster/convert/container.go - About 2 hrs to fix

        Function containerSpecFromGRPC has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
        Open

        func containerSpecFromGRPC(c *swarmapi.ContainerSpec) *types.ContainerSpec {
            if c == nil {
                return nil
            }
            containerSpec := &types.ContainerSpec{
        Severity: Minor
        Found in daemon/cluster/convert/container.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 containerToGRPC has 5 return statements (exceeds 4 allowed).
        Open

        func containerToGRPC(c *types.ContainerSpec) (*swarmapi.ContainerSpec, error) {
            containerSpec := &swarmapi.ContainerSpec{
                Image:          c.Image,
                Labels:         c.Labels,
                Command:        c.Command,
        Severity: Major
        Found in daemon/cluster/convert/container.go - About 35 mins to fix

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

                  if c.Privileges.Seccomp != nil {
                      containerSpec.Privileges.Seccomp = &types.SeccompOpts{
                          Profile: c.Privileges.Seccomp.Profile,
                      }
          
          
          Severity: Major
          Found in daemon/cluster/convert/container.go and 1 other location - About 1 hr to fix
          daemon/cluster/convert/container.go on lines 344..357

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

          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

                  if c.Privileges.Seccomp != nil {
                      containerSpec.Privileges.Seccomp = &swarmapi.Privileges_SeccompOpts{
                          Profile: c.Privileges.Seccomp.Profile,
                      }
          
          
          Severity: Major
          Found in daemon/cluster/convert/container.go and 1 other location - About 1 hr to fix
          daemon/cluster/convert/container.go on lines 74..87

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

          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

                  if m.VolumeOptions != nil {
                      mount.VolumeOptions = &swarmapi.Mount_VolumeOptions{
                          NoCopy:  m.VolumeOptions.NoCopy,
                          Labels:  m.VolumeOptions.Labels,
                          Subpath: m.VolumeOptions.Subpath,
          Severity: Major
          Found in daemon/cluster/convert/container.go and 1 other location - About 1 hr to fix
          daemon/cluster/convert/container.go on lines 122..134

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

          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

                  if m.VolumeOptions != nil {
                      mount.VolumeOptions = &mounttypes.VolumeOptions{
                          NoCopy:  m.VolumeOptions.NoCopy,
                          Labels:  m.VolumeOptions.Labels,
                          Subpath: m.VolumeOptions.Subpath,
          Severity: Major
          Found in daemon/cluster/convert/container.go and 1 other location - About 1 hr to fix
          daemon/cluster/convert/container.go on lines 411..423

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

          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

                  if c.Privileges.SELinuxContext != nil {
                      containerSpec.Privileges.SELinuxContext = &types.SELinuxContext{
                          Disable: c.Privileges.SELinuxContext.Disable,
                          User:    c.Privileges.SELinuxContext.User,
                          Type:    c.Privileges.SELinuxContext.Type,
          Severity: Minor
          Found in daemon/cluster/convert/container.go and 1 other location - About 55 mins to fix
          daemon/cluster/convert/container.go on lines 334..342

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

          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

                  if c.Privileges.SELinuxContext != nil {
                      containerSpec.Privileges.SELinuxContext = &swarmapi.Privileges_SELinuxContext{
                          Disable: c.Privileges.SELinuxContext.Disable,
                          User:    c.Privileges.SELinuxContext.User,
                          Type:    c.Privileges.SELinuxContext.Type,
          Severity: Minor
          Found in daemon/cluster/convert/container.go and 1 other location - About 55 mins to fix
          daemon/cluster/convert/container.go on lines 64..72

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

          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 ulimitsFromGRPC(u []*swarmapi.ContainerSpec_Ulimit) []*container.Ulimit {
              ulimits := make([]*container.Ulimit, len(u))
          
              for i, ulimit := range u {
                  ulimits[i] = &container.Ulimit{
          Severity: Minor
          Found in daemon/cluster/convert/container.go and 1 other location - About 50 mins to fix
          daemon/cluster/convert/container.go on lines 560..572

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

          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 ulimitsToGRPC(u []*container.Ulimit) []*swarmapi.ContainerSpec_Ulimit {
              ulimits := make([]*swarmapi.ContainerSpec_Ulimit, len(u))
          
              for i, ulimit := range u {
                  ulimits[i] = &swarmapi.ContainerSpec_Ulimit{
          Severity: Minor
          Found in daemon/cluster/convert/container.go and 1 other location - About 50 mins to fix
          daemon/cluster/convert/container.go on lines 546..558

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

          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

                  if c.Privileges.AppArmor != nil {
                      containerSpec.Privileges.Apparmor = &swarmapi.Privileges_AppArmorOpts{}
          
                      switch c.Privileges.AppArmor.Mode {
                      case types.AppArmorModeDefault:
          Severity: Minor
          Found in daemon/cluster/convert/container.go and 1 other location - About 45 mins to fix
          daemon/cluster/convert/container.go on lines 89..98

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

          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

                  if c.Privileges.Apparmor != nil {
                      containerSpec.Privileges.AppArmor = &types.AppArmorOpts{}
          
                      switch c.Privileges.Apparmor.Mode {
                      case swarmapi.Privileges_AppArmorOpts_DEFAULT:
          Severity: Minor
          Found in daemon/cluster/convert/container.go and 1 other location - About 45 mins to fix
          daemon/cluster/convert/container.go on lines 359..368

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

          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

          There are no issues that match your filters.

          Category
          Status