docker/docker

View on GitHub
libnetwork/drivers/windows/windows.go

Summary

Maintainability
F
3 days
Test Coverage

File windows.go has 708 lines of code (exceeds 500 allowed). Consider refactoring.
Open

//go:build windows

// Shim for the Host Network Service (HNS) to manage networking for
// Windows Server containers and Hyper-V containers. This module
// is a basic libnetwork driver that passes all the calls to HNS
Severity: Minor
Found in libnetwork/drivers/windows/windows.go - About 7 hrs to fix

    Method driver.CreateNetwork has a Cognitive Complexity of 53 (exceeds 20 allowed). Consider refactoring.
    Open

    func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error {
        if _, err := d.getNetwork(id); err == nil {
            return types.ForbiddenErrorf("network %s exists", id)
        }
    
    
    Severity: Minor
    Found in libnetwork/drivers/windows/windows.go - About 5 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 driver.CreateEndpoint has 114 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error {
        n, err := d.getNetwork(nid)
        if err != nil {
            return err
        }
    Severity: Major
    Found in libnetwork/drivers/windows/windows.go - About 3 hrs to fix

      Method driver.CreateNetwork has 111 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error {
          if _, err := d.getNetwork(id); err == nil {
              return types.ForbiddenErrorf("network %s exists", id)
          }
      
      
      Severity: Major
      Found in libnetwork/drivers/windows/windows.go - About 3 hrs to fix

        Method driver.CreateEndpoint has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
        Open

        func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error {
            n, err := d.getNetwork(nid)
            if err != nil {
                return err
            }
        Severity: Minor
        Found in libnetwork/drivers/windows/windows.go - About 2 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 driver.parseNetworkOptions has 59 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (d *driver) parseNetworkOptions(id string, genericOptions map[string]string) (*networkConfiguration, error) {
            config := &networkConfiguration{Type: d.name}
        
            for label, value := range genericOptions {
                switch label {
        Severity: Minor
        Found in libnetwork/drivers/windows/windows.go - About 1 hr to fix

          Method driver.CreateEndpoint has 13 return statements (exceeds 4 allowed).
          Open

          func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error {
              n, err := d.getNetwork(nid)
              if err != nil {
                  return err
              }
          Severity: Major
          Found in libnetwork/drivers/windows/windows.go - About 1 hr to fix

            Method driver.CreateNetwork has 11 return statements (exceeds 4 allowed).
            Open

            func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error {
                if _, err := d.getNetwork(id); err == nil {
                    return types.ForbiddenErrorf("network %s exists", id)
                }
            
            
            Severity: Major
            Found in libnetwork/drivers/windows/windows.go - About 1 hr to fix

              Function parseEndpointOptions has 7 return statements (exceeds 4 allowed).
              Open

              func parseEndpointOptions(epOptions map[string]interface{}) (*endpointOption, error) {
                  if epOptions == nil {
                      return nil, nil
                  }
              
              
              Severity: Major
              Found in libnetwork/drivers/windows/windows.go - About 45 mins to fix

                Method driver.parseNetworkOptions has 6 return statements (exceeds 4 allowed).
                Open

                func (d *driver) parseNetworkOptions(id string, genericOptions map[string]string) (*networkConfiguration, error) {
                    config := &networkConfiguration{Type: d.name}
                
                    for label, value := range genericOptions {
                        switch label {
                Severity: Major
                Found in libnetwork/drivers/windows/windows.go - About 40 mins to fix

                  Function ConvertPortBindings has 5 return statements (exceeds 4 allowed).
                  Open

                  func ConvertPortBindings(portBindings []types.PortBinding) ([]json.RawMessage, error) {
                      var pbs []json.RawMessage
                  
                      // Enumerate through the port bindings specified by the user and convert
                      // them into the internal structure matching the JSON blob that can be
                  Severity: Major
                  Found in libnetwork/drivers/windows/windows.go - About 35 mins to fix

                    Method driver.Join has 5 return statements (exceeds 4 allowed).
                    Open

                    func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
                        network, err := d.getNetwork(nid)
                        if err != nil {
                            return err
                        }
                    Severity: Major
                    Found in libnetwork/drivers/windows/windows.go - About 35 mins to fix

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

                      func parseEndpointOptions(epOptions map[string]interface{}) (*endpointOption, error) {
                          if epOptions == nil {
                              return nil, nil
                          }
                      
                      
                      Severity: Minor
                      Found in libnetwork/drivers/windows/windows.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

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

                      func (d *driver) parseNetworkOptions(id string, genericOptions map[string]string) (*networkConfiguration, error) {
                          config := &networkConfiguration{Type: d.name}
                      
                          for label, value := range genericOptions {
                              switch label {
                      Severity: Minor
                      Found in libnetwork/drivers/windows/windows.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