dotcloud/docker

View on GitHub
libnetwork/agent.go

Summary

Maintainability
D
2 days
Test Coverage

File agent.go has 782 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package libnetwork

//go:generate protoc -I=. -I=../vendor/ --gogofaster_out=import_path=github.com/docker/docker/libnetwork:. agent.proto

import (
Severity: Major
Found in libnetwork/agent.go - About 1 day to fix

    Method Controller.handleKeyChange has a Cognitive Complexity of 40 (exceeds 20 allowed). Consider refactoring.
    Open

    func (c *Controller) handleKeyChange(keys []*types.EncryptionKey) error {
        drvEnc := discoverapi.DriverEncryptionUpdate{}
    
        agent := c.getAgent()
        if agent == nil {
    Severity: Minor
    Found in libnetwork/agent.go - About 3 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 Controller.handleKeyChange has 87 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (c *Controller) handleKeyChange(keys []*types.EncryptionKey) error {
        drvEnc := discoverapi.DriverEncryptionUpdate{}
    
        agent := c.getAgent()
        if agent == nil {
    Severity: Major
    Found in libnetwork/agent.go - About 2 hrs to fix

      Method Controller.handleEpTableEvent has 76 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (c *Controller) handleEpTableEvent(ev events.Event) {
          var (
              nid   string
              eid   string
              value []byte
      Severity: Major
      Found in libnetwork/agent.go - About 2 hrs to fix

        Method Controller.handleEpTableEvent has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
        Open

        func (c *Controller) handleEpTableEvent(ev events.Event) {
            var (
                nid   string
                eid   string
                value []byte
        Severity: Minor
        Found in libnetwork/agent.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 Network.Services has 62 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (n *Network) Services() map[string]ServiceInfo {
            agent, ok := n.clusterAgent()
            if !ok {
                return nil
            }
        Severity: Minor
        Found in libnetwork/agent.go - About 1 hr to fix

          Method Endpoint.addServiceInfoToCluster has 8 return statements (exceeds 4 allowed).
          Open

          func (ep *Endpoint) addServiceInfoToCluster(sb *Sandbox) error {
              if len(ep.dnsNames) == 0 || ep.Iface() == nil || ep.Iface().Address() == nil {
                  return nil
              }
          
          
          Severity: Major
          Found in libnetwork/agent.go - About 50 mins to fix

            Method Controller.handleEpTableEvent has 7 return statements (exceeds 4 allowed).
            Open

            func (c *Controller) handleEpTableEvent(ev events.Event) {
                var (
                    nid   string
                    eid   string
                    value []byte
            Severity: Major
            Found in libnetwork/agent.go - About 45 mins to fix

              Method Controller.handleKeyChange has 6 return statements (exceeds 4 allowed).
              Open

              func (c *Controller) handleKeyChange(keys []*types.EncryptionKey) error {
                  drvEnc := discoverapi.DriverEncryptionUpdate{}
              
                  agent := c.getAgent()
                  if agent == nil {
              Severity: Major
              Found in libnetwork/agent.go - About 40 mins to fix

                Method Endpoint.deleteServiceInfoFromCluster has 6 return statements (exceeds 4 allowed).
                Open

                func (ep *Endpoint) deleteServiceInfoFromCluster(sb *Sandbox, fullRemove bool, method string) error {
                    if len(ep.dnsNames) == 0 {
                        return nil
                    }
                
                
                Severity: Major
                Found in libnetwork/agent.go - About 40 mins to fix

                  Method Network.Services has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (n *Network) Services() map[string]ServiceInfo {
                      agent, ok := n.clusterAgent()
                      if !ok {
                          return nil
                      }
                  Severity: Minor
                  Found in libnetwork/agent.go - About 35 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

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

                  func (ep *Endpoint) deleteServiceInfoFromCluster(sb *Sandbox, fullRemove bool, method string) error {
                      if len(ep.dnsNames) == 0 {
                          return nil
                      }
                  
                  
                  Severity: Minor
                  Found in libnetwork/agent.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