dotcloud/docker

View on GitHub
libnetwork/sandbox.go

Summary

Maintainability
D
1 day
Test Coverage

Sandbox has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

func (sb *Sandbox) processOptions(options ...SandboxOption) {
    for _, opt := range options {
        if opt != nil {
            opt(sb)
        }
Severity: Minor
Found in libnetwork/sandbox.go - About 3 hrs to fix

    File sandbox.go has 551 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package libnetwork
    
    import (
        "context"
        "encoding/json"
    Severity: Minor
    Found in libnetwork/sandbox.go - About 3 hrs to fix

      Method Sandbox.clearNetworkResources has 57 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (sb *Sandbox) clearNetworkResources(origEp *Endpoint) error {
          ep := sb.GetEndpoint(origEp.id)
          if ep == nil {
              return fmt.Errorf("could not find the sandbox endpoint data for endpoint %s",
                  origEp.id)
      Severity: Minor
      Found in libnetwork/sandbox.go - About 1 hr to fix

        Method Sandbox.delete has 54 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (sb *Sandbox) delete(ctx context.Context, force bool) error {
            sb.mu.Lock()
            if sb.inDelete {
                sb.mu.Unlock()
                return types.ForbiddenErrorf("another sandbox delete in progress")
        Severity: Minor
        Found in libnetwork/sandbox.go - About 1 hr to fix

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

          func (sb *Sandbox) delete(ctx context.Context, force bool) error {
              sb.mu.Lock()
              if sb.inDelete {
                  sb.mu.Unlock()
                  return types.ForbiddenErrorf("another sandbox delete in progress")
          Severity: Minor
          Found in libnetwork/sandbox.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 Sandbox.resolveName has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          func (sb *Sandbox) resolveName(ctx context.Context, nameOrAlias string, networkName string, epList []*Endpoint, lookupAlias bool, ipType int) (_ []net.IP, ipv6Miss bool) {
          Severity: Minor
          Found in libnetwork/sandbox.go - About 45 mins to fix

            Method Sandbox.clearNetworkResources has 6 return statements (exceeds 4 allowed).
            Open

            func (sb *Sandbox) clearNetworkResources(origEp *Endpoint) error {
                ep := sb.GetEndpoint(origEp.id)
                if ep == nil {
                    return fmt.Errorf("could not find the sandbox endpoint data for endpoint %s",
                        origEp.id)
            Severity: Major
            Found in libnetwork/sandbox.go - About 40 mins to fix

              Method Sandbox.ResolveName has 5 return statements (exceeds 4 allowed).
              Open

              func (sb *Sandbox) ResolveName(ctx context.Context, name string, ipType int) ([]net.IP, bool) {
                  // Embedded server owns the docker network domain. Resolution should work
                  // for both container_name and container_name.network_name
                  // We allow '.' in service name and network name. For a name a.b.c.d the
                  // following have to tried;
              Severity: Major
              Found in libnetwork/sandbox.go - About 35 mins to fix

                Method Endpoint.Less has 5 return statements (exceeds 4 allowed).
                Open

                func (epi *Endpoint) Less(epj *Endpoint) bool {
                    var prioi, prioj int
                
                    sbi, _ := epi.getSandbox()
                    sbj, _ := epj.getSandbox()
                Severity: Major
                Found in libnetwork/sandbox.go - About 35 mins to fix

                  Method Sandbox.clearNetworkResources has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (sb *Sandbox) clearNetworkResources(origEp *Endpoint) error {
                      ep := sb.GetEndpoint(origEp.id)
                      if ep == nil {
                          return fmt.Errorf("could not find the sandbox endpoint data for endpoint %s",
                              origEp.id)
                  Severity: Minor
                  Found in libnetwork/sandbox.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