Showing 1,885 of 1,885 total issues
Method NetworkDB.handleTableEvent
has 5 return statements (exceeds 4 allowed). 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
Function AddInterfaceFirewalld
has 5 return statements (exceeds 4 allowed). Open
func AddInterfaceFirewalld(intf string) error {
if !firewalldRunning {
return nil
}
Function Register
has 5 return statements (exceeds 4 allowed). Open
func Register(r ipamapi.Registerer, pg plugingetter.PluginGetter, lAddrPools, gAddrPools []*ipamutils.NetworkToSplit) error {
if err := defaultipam.Register(r, lAddrPools, gAddrPools); err != nil {
return err
}
if err := windowsipam.Register(r); err != nil {
Method Endpoint.Less
has 5 return statements (exceeds 4 allowed). Open
func (epi *Endpoint) Less(epj *Endpoint) bool {
var prioi, prioj int
sbi, _ := epi.getSandbox()
sbj, _ := epj.getSandbox()
Function GenerateFromModel
has 5 return statements (exceeds 4 allowed). 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)
Method Controller.rmServiceBinding
has 5 return statements (exceeds 4 allowed). 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,
Method NetworkDB.changeNodeState
has 5 return statements (exceeds 4 allowed). 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)
}
Method driver.Leave
has 5 return statements (exceeds 4 allowed). Open
func (d *driver) Leave(nid, eid string) error {
network, err := d.getNetwork(nid)
if err != nil {
return types.InternalMaskableErrorf("%s", err)
}
Method driver.createNetwork
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (d *driver) createNetwork(config *networkConfiguration) (err error) {
// Initialize handle when needed
d.Lock()
if d.nlh == 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
Function setupIPTablesInternal
has 5 return statements (exceeds 4 allowed). Open
func setupIPTablesInternal(ipVer iptables.IPVersion, config *networkConfiguration, addr *net.IPNet, hairpin, enable bool) error {
var (
address = addr.String()
skipDNAT = iptRule{ipv: ipVer, table: iptables.Nat, chain: DockerChain, args: []string{"-i", config.BridgeName, "-j", "RETURN"}}
outRule = iptRule{ipv: ipVer, table: iptables.Filter, chain: "FORWARD", args: []string{"-i", config.BridgeName, "!", "-o", config.BridgeName, "-j", "ACCEPT"}}
Method Endpoint.DriverInfo
has 5 return statements (exceeds 4 allowed). 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
func getPluginClient(p plugingetter.CompatPlugin) (*plugins.Client, error) {
if v1, ok := p.(plugingetter.PluginWithV1Client); ok {
return v1.Client(), nil
}
Method bridgeEndpoint.UnmarshalJSON
has 5 return statements (exceeds 4 allowed). Open
func (ep *bridgeEndpoint) UnmarshalJSON(b []byte) error {
var (
err error
epMap map[string]interface{}
)
Method bridgeNetwork.setPerPortIptables
has 5 return statements (exceeds 4 allowed). 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 NetworkDB.clusterInit
has 5 return statements (exceeds 4 allowed). Open
func (nDB *NetworkDB) clusterInit() error {
nDB.lastStatsTimestamp = time.Now()
nDB.lastHealthTimestamp = nDB.lastStatsTimestamp
config := memberlist.DefaultLANConfig()
Method Resolver.forwardExtDNS
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. 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 bridgeInterface.programIPv6Addresses
has 5 return statements (exceeds 4 allowed). Open
func (i *bridgeInterface) programIPv6Addresses(config *networkConfiguration) error {
// Remember the configured addresses.
i.bridgeIPv6 = config.AddressIPv6
i.gatewayIPv6 = config.AddressIPv6.IP
Method driver.CreateEndpoint
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. 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 endpoint.UnmarshalJSON
has 5 return statements (exceeds 4 allowed). Open
func (ep *endpoint) UnmarshalJSON(b []byte) error {
var (
err error
epMap map[string]interface{}
)
Function configurePortBindingIPv6
has 5 return statements (exceeds 4 allowed). Open
func configurePortBindingIPv6(disableNAT bool, bnd types.PortBinding, containerIP, defHostIP net.IP) (portBindingReq, bool) {
if containerIP == nil {
return portBindingReq{}, false
}
if len(bnd.HostIP) > 0 && bnd.HostIP.To4() != nil {