dotcloud/docker

View on GitHub
volume/local/local_unix.go

Summary

Maintainability
A
3 hrs
Test Coverage

Method Root.validateOpts has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
Open

func (r *Root) validateOpts(opts map[string]string) error {
    if len(opts) == 0 {
        return nil
    }
    for opt := range opts {
Severity: Minor
Found in volume/local/local_unix.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 Root.validateOpts has 8 return statements (exceeds 4 allowed).
Open

func (r *Root) validateOpts(opts map[string]string) error {
    if len(opts) == 0 {
        return nil
    }
    for opt := range opts {
Severity: Major
Found in volume/local/local_unix.go - About 50 mins to fix

    Function getMountOptions has 6 return statements (exceeds 4 allowed).
    Open

    func getMountOptions(opts *optsConfig, resolveIP func(string, string) (*net.IPAddr, error)) (mountDevice string, mountOpts string, _ error) {
        if opts.MountDevice == "" {
            return "", "", fmt.Errorf("missing device in volume options")
        }
    
    
    Severity: Major
    Found in volume/local/local_unix.go - About 40 mins to fix

      Function getMountOptions has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
      Open

      func getMountOptions(opts *optsConfig, resolveIP func(string, string) (*net.IPAddr, error)) (mountDevice string, mountOpts string, _ error) {
          if opts.MountDevice == "" {
              return "", "", fmt.Errorf("missing device in volume options")
          }
      
      
      Severity: Minor
      Found in volume/local/local_unix.go - About 25 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