Showing 1,468 of 1,914 total issues
Method Endpoint.assignAddressVersion
has 5 return statements (exceeds 4 allowed). Open
Open
func (ep *Endpoint) assignAddressVersion(ipVer int, ipam ipamapi.Ipam) error {
var (
poolID *string
address **net.IPNet
prefAdd net.IP
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 NetworkDB.handleTableEvent
has 5 return statements (exceeds 4 allowed). Open
Open
func (nDB *NetworkDB) handleTableEvent(tEvent *TableEvent, isBulkSync bool) bool {
// Update our local clock if the received messages has newer time.
nDB.tableClock.Witness(tEvent.LTime)
// Ignore the table events for networks that are in the process of going away
Method ResolvConf.WriteFile
has 5 return statements (exceeds 4 allowed). Open
Open
func (rc *ResolvConf) WriteFile(path, hashPath string, perm os.FileMode) error {
content, err := rc.Generate(true)
if err != nil {
return err
}
Method NetworkDB.handleTableMessage
has 5 return statements (exceeds 4 allowed). Open
Open
func (nDB *NetworkDB) handleTableMessage(buf []byte, isBulkSync bool) {
var tEvent TableEvent
if err := proto.Unmarshal(buf, &tEvent); err != nil {
log.G(context.TODO()).Errorf("Error decoding table event message: %v", err)
return
Method allocator.RequestPool
has 5 return statements (exceeds 4 allowed). Open
Open
func (a *allocator) RequestPool(req ipamapi.PoolRequest) (ipamapi.AllocatedPool, error) {
if req.AddressSpace != defaultAddressSpace {
return ipamapi.AllocatedPool{}, types.InvalidParameterErrorf("unknown address space: %s", req.AddressSpace)
}
if req.Pool != "" {
Method IPTable.NewChain
has 5 return statements (exceeds 4 allowed). Open
Open
func (iptable IPTable) NewChain(name string, table Table) (*ChainInfo, error) {
if name == "" {
return nil, fmt.Errorf("could not create chain: chain name is empty")
}
if table == "" {
Method addrSpace.releaseAddress
has 5 return statements (exceeds 4 allowed). Open
Open
func (aSpace *addrSpace) releaseAddress(nw, sub netip.Prefix, address netip.Addr) error {
aSpace.mu.Lock()
defer aSpace.mu.Unlock()
p, ok := aSpace.subnets[nw]
Function deleteEpFromResolverImpl
has 5 return statements (exceeds 4 allowed). Open
Open
func deleteEpFromResolverImpl(
epName string,
epIface *EndpointInterface,
resolvers []*Resolver,
hnsEndpoints []hcsshim.HNSEndpoint,
Method Network.Services
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func (n *Network) Services() map[string]ServiceInfo {
agent, ok := n.clusterAgent()
if !ok {
return nil
}
- 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 Endpoint.Info
has 5 return statements (exceeds 4 allowed). Open
Open
func (ep *Endpoint) Info() EndpointInfo {
if ep.sandboxID != "" {
return ep
}
n, err := ep.getNetworkFromStore()
Method cache.kmap
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *cache) kmap(kvObject KVObject) (kvMap, error) {
var err error
c.mu.Lock()
keyPrefix := Key(kvObject.KeyPrefix()...)
Method Controller.rmServiceBinding
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *Controller) rmServiceBinding(svcName, svcID, nID, eID, containerName string, vip net.IP, ingressPorts []*PortConfig, serviceAliases []string, taskAliases []string, ip net.IP, method string, deleteSvcRecords bool, fullRemove bool) error {
var rmService bool
skey := serviceKey{
id: svcID,
Function DelInterfaceFirewalld
has 5 return statements (exceeds 4 allowed). Open
Open
func DelInterfaceFirewalld(intf string) error {
if !firewalldRunning {
return nil
}
Function GenerateFromModel
has 5 return statements (exceeds 4 allowed). Open
Open
func GenerateFromModel(options Generic, model interface{}) (interface{}, error) {
modType := reflect.TypeOf(model)
// If the model is of pointer type, we need to dereference for New.
resType := reflect.TypeOf(model)
Function PoolIDFromString
has 5 return statements (exceeds 4 allowed). Open
Open
func PoolIDFromString(str string) (pID PoolID, err error) {
if str == "" {
return pID, types.InvalidParameterErrorf("invalid string form for subnetkey: %s", str)
}
Method NetworkDB.changeNodeState
has 5 return statements (exceeds 4 allowed). Open
Open
func (nDB *NetworkDB) changeNodeState(nodeName string, newState nodeState) (bool, error) {
n, currState, m := nDB.findNode(nodeName)
if n == nil {
return false, fmt.Errorf("node %s not found", nodeName)
}
Function getDynamicPortRange
has 5 return statements (exceeds 4 allowed). Open
Open
func getDynamicPortRange() (start int, end int, err error) {
portRangeKernelSysctl := []string{"net.inet.ip.portrange.hifirst", "net.ip.portrange.hilast"}
portRangeLowCmd := exec.Command("/sbin/sysctl", portRangeKernelSysctl[0])
var portRangeLowOut bytes.Buffer
portRangeLowCmd.Stdout = &portRangeLowOut
Method Network.addLBBackend
has 5 return statements (exceeds 4 allowed). Open
Open
func (n *Network) addLBBackend(ip net.IP, lb *loadBalancer) {
if len(lb.vip) == 0 {
return
}
Method Controller.NetworkByName
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *Controller) NetworkByName(name string) (*Network, error) {
if name == "" {
return nil, ErrInvalidName(name)
}
var n *Network