dotcloud/docker

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

Summary

Maintainability
F
3 days
Test Coverage

File windows.go has 725 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 57 (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 6 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 118 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (d *driver) CreateEndpoint(ctx context.Context, nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error {
        ctx, span := otel.Tracer("").Start(ctx, fmt.Sprintf("libnetwork.drivers.windows_%s.CreateEndpoint", d.name), trace.WithAttributes(
            attribute.String("nid", nid),
            attribute.String("eid", eid)))
        defer span.End()
    Severity: Major
    Found in libnetwork/drivers/windows/windows.go - About 3 hrs to fix

      Method driver.CreateNetwork has 116 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(ctx context.Context, nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error {
            ctx, span := otel.Tracer("").Start(ctx, fmt.Sprintf("libnetwork.drivers.windows_%s.CreateEndpoint", d.name), trace.WithAttributes(
                attribute.String("nid", nid),
                attribute.String("eid", eid)))
            defer span.End()
        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(ctx context.Context, nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error {
              ctx, span := otel.Tracer("").Start(ctx, fmt.Sprintf("libnetwork.drivers.windows_%s.CreateEndpoint", d.name), trace.WithAttributes(
                  attribute.String("nid", nid),
                  attribute.String("eid", eid)))
              defer span.End()
          Severity: Major
          Found in libnetwork/drivers/windows/windows.go - About 1 hr to fix

            Method driver.CreateNetwork has 12 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

                  Method driver.Join has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  func (d *driver) Join(ctx context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
                  Severity: Minor
                  Found in libnetwork/drivers/windows/windows.go - About 35 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(ctx context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
                          ctx, span := otel.Tracer("").Start(ctx, fmt.Sprintf("libnetwork.drivers.windows_%s.Join", d.name), trace.WithAttributes(
                              attribute.String("nid", nid),
                              attribute.String("eid", eid),
                              attribute.String("sboxKey", sboxKey)))
                      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