Showing 1,904 of 1,904 total issues
Method Controller.NewSandbox
has 7 return statements (exceeds 4 allowed). Open
func (c *Controller) NewSandbox(ctx context.Context, containerID string, options ...SandboxOption) (_ *Sandbox, retErr error) {
if containerID == "" {
return nil, types.InvalidParameterErrorf("invalid container ID")
}
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) {
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.addEndpointNameResolution
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func (c *Controller) addEndpointNameResolution(svcName, svcID, nID, eID, containerName string, vip net.IP, serviceAliases, taskAliases []string, ip net.IP, addService bool, method string) error {
Method PortAllocator.RequestPortsInRange
has 7 return statements (exceeds 4 allowed). Open
func (p *PortAllocator) RequestPortsInRange(ips []net.IP, proto string, portStart, portEnd int) (int, error) {
if proto != "tcp" && proto != "udp" && proto != "sctp" {
return 0, ErrUnknownProtocol
}
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 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.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
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 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 networkConfiguration.Validate
has 7 return statements (exceeds 4 allowed). Open
func (c *networkConfiguration) Validate() error {
if c.Mtu < 0 {
return ErrInvalidMtu(c.Mtu)
}
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.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
}
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 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 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 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"))
Method Client.ImagePush
has 7 return statements (exceeds 4 allowed). Open
func (cli *Client) ImagePush(ctx context.Context, image string, options image.PushOptions) (io.ReadCloser, error) {
ref, err := reference.ParseNormalizedNamed(image)
if err != nil {
return nil, err
}
Method Client.PluginInstall
has 7 return statements (exceeds 4 allowed). Open
func (cli *Client) PluginInstall(ctx context.Context, name string, options types.PluginInstallOptions) (rc io.ReadCloser, err error) {
query := url.Values{}
if _, err := reference.ParseNormalizedNamed(options.RemoteRef); err != nil {
return nil, errors.Wrap(err, "invalid remote reference")
}
Method Client.imageBuildOptionsToQuery
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (cli *Client) imageBuildOptionsToQuery(ctx context.Context, options types.ImageBuildOptions) (url.Values, error) {
query := url.Values{
"t": options.Tags,
"securityopt": options.SecurityOpt,
"extrahosts": options.ExtraHosts,
- 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"