Showing 1,468 of 1,914 total issues
Function New
has 7 return statements (exceeds 4 allowed). Open
func New(cfgOptions ...config.Option) (*Controller, error) {
cfg := config.New(cfgOptions...)
store, err := datastore.New(cfg.DataDir, cfg.DatastoreBucket)
if err != nil {
return nil, fmt.Errorf("libnet controller initialization: %w", err)
Method Controller.deleteEndpointNameResolution
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func (c *Controller) deleteEndpointNameResolution(svcName, svcID, nID, eID, containerName string, vip net.IP, serviceAliases, taskAliases []string, ip net.IP, rmService, multipleEntries bool, method string) error {
Method IPAMData.Validate
has 7 return statements (exceeds 4 allowed). Open
func (i *IPAMData) Validate() error {
var isV6 bool
if i.Pool == nil {
return types.InvalidParameterErrorf("invalid pool")
}
Method Sandbox.resolveName
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func (sb *Sandbox) resolveName(ctx context.Context, nameOrAlias string, networkName string, epList []*Endpoint, lookupAlias bool, ipType int) (_ []net.IP, ipv6Miss bool) {
Method NetworkDB.handleNetworkEvent
has 7 return statements (exceeds 4 allowed). Open
func (nDB *NetworkDB) handleNetworkEvent(nEvent *NetworkEvent) bool {
// Update our local clock if the received messages has newer
// time.
nDB.networkClock.Witness(nEvent.LTime)
Method driver.CreateNetwork
has 7 return statements (exceeds 4 allowed). Open
func (d *driver) CreateNetwork(nid string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error {
// reject a null v4 network if ipv4 is required
if v, ok := option[netlabel.EnableIPv4]; ok && v.(bool) {
if len(ipV4Data) == 0 || ipV4Data[0].Pool.String() == "0.0.0.0/0" {
return errdefs.InvalidParameter(fmt.Errorf("ipv4 pool is empty"))
Function bindTCPOrUDP
has 7 return statements (exceeds 4 allowed). Open
func bindTCPOrUDP(cfg portBindingReq, port, typ, proto int) (_ portBinding, retErr error) {
pb := portBinding{PortBinding: cfg.PortBinding.GetCopy()}
pb.HostPort = uint16(port)
pb.HostPortEnd = pb.HostPort
pb.childHostIP = cfg.childHostIP
Method Endpoint.DriverInfo
has 7 return statements (exceeds 4 allowed). Open
func (ep *Endpoint) DriverInfo() (map[string]interface{}, error) {
ep, err := ep.retrieveFromStore()
if err != nil {
return nil, err
}
Method driver.CreateEndpoint
has 7 return statements (exceeds 4 allowed). Open
func (d *driver) CreateEndpoint(_ context.Context, nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error {
var err error
if err = validateID(nid, eid); err != nil {
return err
}
Method driver.EventNotify
has 7 return statements (exceeds 4 allowed). Open
func (d *driver) EventNotify(etype driverapi.EventType, nid, tableName, key string, value []byte) {
if tableName != ovPeerTable {
log.G(context.TODO()).Errorf("Unexpected table notification for table %s received", tableName)
return
}
Method PortMapper.MapRange
has 7 return statements (exceeds 4 allowed). Open
func (pm *PortMapper) MapRange(container net.Addr, hostIP net.IP, hostPortStart, hostPortEnd int) (host net.Addr, retErr error) {
pm.lock.Lock()
defer pm.lock.Unlock()
var (
Method driver.createNetwork
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (d *driver) createNetwork(config *networkConfiguration) (err error) {
// Initialize handle when needed
d.Lock()
if d.nlh.Handle == nil {
d.nlh = ns.NlHandle()
- 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 NetworkDB.gossip
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (nDB *NetworkDB) gossip() {
networkNodes := make(map[string][]string)
nDB.RLock()
thisNodeNetworks := nDB.networks[nDB.config.NodeID]
for nid := range thisNodeNetworks {
- 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
Function NewPortDriverClient
has 7 return statements (exceeds 4 allowed). Open
func NewPortDriverClient(ctx context.Context) (*PortDriverClient, error) {
stateDir := os.Getenv("ROOTLESSKIT_STATE_DIR")
if stateDir == "" {
return nil, errors.New("$ROOTLESSKIT_STATE_DIR needs to be set")
}
Method driver.NetworkAllocate
has 7 return statements (exceeds 4 allowed). Open
func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
if id == "" {
return nil, fmt.Errorf("invalid network id for overlay network")
}
Method driver.configure
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (d *driver) configure(option map[string]interface{}) error {
var (
config configuration
err error
natChain *iptables.ChainInfo
- 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
Function createVlanLink
has 7 return statements (exceeds 4 allowed). Open
func createVlanLink(parentName string) error {
if strings.Contains(parentName, ".") {
parent, vidInt, err := parseVlan(parentName)
if err != nil {
return err
Method networkConfiguration.Validate
has 7 return statements (exceeds 4 allowed). Open
func (c *networkConfiguration) Validate() error {
if c.Mtu < 0 {
return ErrInvalidMtu(c.Mtu)
}
Method cnmNetworkAllocator.IsServiceAllocated
has 7 return statements (exceeds 4 allowed). Open
func (na *cnmNetworkAllocator) IsServiceAllocated(s *api.Service, flags ...func(*networkallocator.ServiceAllocationOpts)) bool {
specNetworks := serviceNetworks(s)
// If endpoint mode is VIP and allocator does not have the
// service in VIP allocated set then it needs to be allocated.
Method Store.lookup
has 7 return statements (exceeds 4 allowed). Open
func (s *Store) lookup(name string, mode int) (volume.Driver, error) {
if name == "" {
return nil, errdefs.InvalidParameter(errors.New("driver name cannot be empty"))
}
s.driverLock.Lock(name)