Showing 1,468 of 1,914 total issues
Method driver.createNetwork
has 5 return statements (exceeds 4 allowed). Open
Open
func (d *driver) createNetwork(config *networkConfiguration) (err error) {
// Initialize handle when needed
d.Lock()
if d.nlh.Handle == nil {
d.nlh = ns.NlHandle()
Method Resolver.forwardExtDNS
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func (r *Resolver) forwardExtDNS(ctx context.Context, proto string, remoteAddr net.Addr, query *dns.Msg) *dns.Msg {
ctx, span := otel.Tracer("").Start(ctx, "resolver.forwardExtDNS")
defer span.End()
proxyDNS := r.proxyDNS.Load()
- 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 driver.CreateEndpoint
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func (d *driver) CreateEndpoint(_ context.Context, nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) (retErr error) {
if ifInfo == nil {
return errors.New("must not be called with nil InterfaceInfo")
}
- 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 Client.ConfigInspectWithRaw
has 5 return statements (exceeds 4 allowed). Open
Open
func (cli *Client) ConfigInspectWithRaw(ctx context.Context, id string) (swarm.Config, []byte, error) {
if id == "" {
return swarm.Config{}, nil, objectNotFoundError{object: "config", id: id}
}
if err := cli.NewVersionError(ctx, "1.30", "config inspect"); err != nil {
Method endpoint.UnmarshalJSON
has 5 return statements (exceeds 4 allowed). Open
Open
func (ep *endpoint) UnmarshalJSON(b []byte) error {
var (
err error
epMap map[string]interface{}
)
Method Client.VolumesPrune
has 5 return statements (exceeds 4 allowed). Open
Open
func (cli *Client) VolumesPrune(ctx context.Context, pruneFilters filters.Args) (volume.PruneReport, error) {
if err := cli.NewVersionError(ctx, "1.25", "volume prune"); err != nil {
return volume.PruneReport{}, err
}
Method Client.SecretInspectWithRaw
has 5 return statements (exceeds 4 allowed). Open
Open
func (cli *Client) SecretInspectWithRaw(ctx context.Context, id string) (swarm.Secret, []byte, error) {
if err := cli.NewVersionError(ctx, "1.25", "secret inspect"); err != nil {
return swarm.Secret{}, nil, err
}
if id == "" {
Method Client.NetworksPrune
has 5 return statements (exceeds 4 allowed). Open
Open
func (cli *Client) NetworksPrune(ctx context.Context, pruneFilters filters.Args) (network.PruneReport, error) {
if err := cli.NewVersionError(ctx, "1.25", "network prune"); err != nil {
return network.PruneReport{}, err
}
Function Exec
has 5 return statements (exceeds 4 allowed). Open
Open
func Exec(ctx context.Context, apiClient client.APIClient, id string, cmd []string, ops ...func(*container.ExecOptions)) (ExecResult, error) {
// prepare exec
execOptions := container.ExecOptions{
AttachStdout: true,
AttachStderr: true,
Function makePluginAdapter
has 5 return statements (exceeds 4 allowed). Open
Open
func makePluginAdapter(p plugingetter.CompatPlugin) (*volumeDriverAdapter, error) {
if pc, ok := p.(plugingetter.PluginWithV1Client); ok {
return &volumeDriverAdapter{name: p.Name(), scopePath: p.ScopedPath, proxy: &volumeDriverProxy{pc.Client()}}, nil
}
Function ConvertPortBindings
has 5 return statements (exceeds 4 allowed). Open
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
Method Provider.NewAllocator
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *Provider) NewAllocator(netConfig *networkallocator.Config) (networkallocator.NetworkAllocator, error) {
na := &cnmNetworkAllocator{
networks: make(map[string]*network),
services: make(map[string]struct{}),
tasks: make(map[string]struct{}),
Method driver.peerDelete
has 5 return statements (exceeds 4 allowed). Open
Open
func (d *driver) peerDelete(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, peerMac net.HardwareAddr, vtep net.IP, updateDb bool) error {
log.G(context.TODO()).Infof("WINOVERLAY: Enter peerDelete for endpoint %s and peer ip %s", eid, peerIP.String())
if err := validateID(nid, eid); err != nil {
return err
Function delVlanLink
has 5 return statements (exceeds 4 allowed). Open
Open
func delVlanLink(linkName string) error {
if strings.Contains(linkName, ".") {
_, _, err := parseVlan(linkName)
if err != nil {
return err
Method Sandbox.setupDefaultGW
has 5 return statements (exceeds 4 allowed). Open
Open
func (sb *Sandbox) setupDefaultGW() error {
// check if the container already has a GW endpoint
if ep := sb.getEndpointInGWNetwork(); ep != nil {
return nil
}
Method Client.PluginUpgrade
has 5 return statements (exceeds 4 allowed). Open
Open
func (cli *Client) PluginUpgrade(ctx context.Context, name string, options types.PluginInstallOptions) (rc io.ReadCloser, err error) {
if err := cli.NewVersionError(ctx, "1.26", "plugin upgrade"); err != nil {
return nil, err
}
query := url.Values{}
Method bridgeInterface.programIPv6Addresses
has 5 return statements (exceeds 4 allowed). Open
Open
func (i *bridgeInterface) programIPv6Addresses(config *networkConfiguration) error {
// Remember the configured addresses.
i.bridgeIPv6 = config.AddressIPv6
i.gatewayIPv6 = config.AddressIPv6.IP
Method Client.ContainerWait
has 5 return statements (exceeds 4 allowed). Open
Open
func (cli *Client) ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error) {
resultC := make(chan container.WaitResponse)
errC := make(chan error, 1)
// Make sure we negotiated (if the client is configured to do so),
Method cnmNetworkAllocator.Allocate
has 5 return statements (exceeds 4 allowed). Open
Open
func (na *cnmNetworkAllocator) Allocate(n *api.Network) error {
if _, ok := na.networks[n.ID]; ok {
return fmt.Errorf("network %s already allocated", n.ID)
}
Method Client.BuildCachePrune
has 5 return statements (exceeds 4 allowed). Open
Open
func (cli *Client) BuildCachePrune(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error) {
if err := cli.NewVersionError(ctx, "1.31", "build prune"); err != nil {
return nil, err
}