Showing 1,468 of 1,914 total issues
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 Store.PutObjectAtomic
has 5 return statements (exceeds 4 allowed). Open
Open
func (ds *Store) PutObjectAtomic(kvObject KVObject) error {
ds.mu.Lock()
defer ds.mu.Unlock()
if kvObject == nil {
Method addrSpace.requestAddress
has 5 return statements (exceeds 4 allowed). Open
Open
func (aSpace *addrSpace) requestAddress(nw, sub netip.Prefix, prefAddress netip.Addr, opts map[string]string) (netip.Addr, error) {
aSpace.mu.Lock()
defer aSpace.mu.Unlock()
p, ok := aSpace.subnets[nw]
Method Endpoint.DriverInfo
has 5 return statements (exceeds 4 allowed). Open
Open
func (ep *Endpoint) DriverInfo() (map[string]interface{}, error) {
ep, err := ep.retrieveFromStore()
if err != nil {
return nil, err
}
Function getPluginClient
has 5 return statements (exceeds 4 allowed). Open
Open
func getPluginClient(p plugingetter.CompatPlugin) (*plugins.Client, error) {
if v1, ok := p.(plugingetter.PluginWithV1Client); ok {
return v1.Client(), 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 driver.CreateEndpoint
has 5 return statements (exceeds 4 allowed). Open
Open
func (d *driver) CreateEndpoint(ctx context.Context, nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error {
if err := validateID(nid, eid); err != nil {
return err
}
n, err := d.getNetwork(nid)
Method bridgeEndpoint.UnmarshalJSON
has 5 return statements (exceeds 4 allowed). Open
Open
func (ep *bridgeEndpoint) UnmarshalJSON(b []byte) error {
var (
err error
epMap map[string]interface{}
)
Method networkConfiguration.Conflicts
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *networkConfiguration) Conflicts(o *networkConfiguration) error {
if o == nil {
return errors.New("same configuration")
}
Method NetworkDB.clusterInit
has 5 return statements (exceeds 4 allowed). Open
Open
func (nDB *NetworkDB) clusterInit() error {
nDB.lastStatsTimestamp = time.Now()
nDB.lastHealthTimestamp = nDB.lastStatsTimestamp
config := memberlist.DefaultLANConfig()
Function configurePortBindingIPv6
has 5 return statements (exceeds 4 allowed). Open
Open
func configurePortBindingIPv6(
ctx context.Context,
pdc portDriverClient,
disableNAT bool,
bnd types.PortBinding,
Method bridgeNetwork.setPerPortIptables
has 5 return statements (exceeds 4 allowed). Open
Open
func (n *bridgeNetwork) setPerPortIptables(b portBinding, enable bool) error {
if (b.IP.To4() != nil) != (b.HostIP.To4() != nil) {
// The binding is between containerV4 and hostV6 (not vice-versa as that
// will have been rejected earlier). It's handled by docker-proxy, so no
// additional iptables rules are required.
Method driver.configure
has 5 return statements (exceeds 4 allowed). Open
Open
func (d *driver) configure(option map[string]interface{}) error {
var (
config configuration
err error
natChain *iptables.ChainInfo
Method driver.createNetwork
has 5 return statements (exceeds 4 allowed). Open
Open
func (d *driver) createNetwork(config *configuration) (bool, error) {
foundExisting := false
networkList := d.getNetworks()
for _, nw := range networkList {
if config.Parent == nw.config.Parent {
Function createMacVlan
has 5 return statements (exceeds 4 allowed). Open
Open
func createMacVlan(containerIfName, parent, macvlanMode string) (string, error) {
// Set the macvlan mode. Default is bridge mode
mode, err := setMacVlanMode(macvlanMode)
if err != nil {
return "", fmt.Errorf("Unsupported %s macvlan mode: %v", macvlanMode, 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
Function bindSCTP
has 5 return statements (exceeds 4 allowed). Open
Open
func bindSCTP(cfg portBindingReq, port int) (_ portBinding, retErr error) {
pb := portBinding{PortBinding: cfg.GetCopy()}
pb.HostPort = uint16(port)
pb.HostPortEnd = pb.HostPort
pb.childHostIP = cfg.childHostIP
Method NetworkDB.bulkSyncTables
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func (nDB *NetworkDB) bulkSyncTables() {
var networks []string
nDB.RLock()
for nid, network := range nDB.networks[nDB.config.NodeID] {
if network.leaving {
- 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.Leave
has 5 return statements (exceeds 4 allowed). Open
Open
func (d *driver) Leave(nid, eid string) error {
network, err := d.getNetwork(nid)
if err != nil {
return types.InternalMaskableErrorf("%s", err)
}
Method driver.RevokeExternalConnectivity
has 5 return statements (exceeds 4 allowed). Open
Open
func (d *driver) RevokeExternalConnectivity(nid, eid string) error {
network, err := d.getNetwork(nid)
if err != nil {
return err
}