libnetwork/sandbox.go
Sandbox
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
Open
func (sb *Sandbox) processOptions(options ...SandboxOption) {
for _, opt := range options {
if opt != nil {
opt(sb)
}
File sandbox.go
has 550 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
package libnetwork
import (
"context"
"encoding/json"
Method Sandbox.clearNetworkResources
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
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)
Method Sandbox.delete
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
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")
Method Sandbox.delete
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
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")
- Read upRead up
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
Open
func (sb *Sandbox) resolveName(ctx context.Context, nameOrAlias string, networkName string, epList []*Endpoint, lookupAlias bool, ipType int) (_ []net.IP, ipv6Miss bool) {
Method Sandbox.clearNetworkResources
has 6 return statements (exceeds 4 allowed). Open
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)
Method Endpoint.Less
has 5 return statements (exceeds 4 allowed). Open
Open
func (epi *Endpoint) Less(epj *Endpoint) bool {
var prioi, prioj int
sbi, _ := epi.getSandbox()
sbj, _ := epj.getSandbox()
Method Sandbox.ResolveName
has 5 return statements (exceeds 4 allowed). Open
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;
Method Sandbox.clearNetworkResources
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
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)
- Read upRead up
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"