Showing 1,885 of 1,885 total issues
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 setupInternalNetworkRules
has 5 return statements (exceeds 4 allowed). Open
Open
func setupInternalNetworkRules(bridgeIface string, addr *net.IPNet, icc, insert bool) error {
var version iptables.IPVersion
var inDropRule, outDropRule iptRule
// Either add or remove the interface from the firewalld zone, if firewalld is running.
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
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
}
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 {
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 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 driver.createNetwork
has 5 return statements (exceeds 4 allowed). Open
Open
func (d *driver) createNetwork(config *networkConfiguration) (err error) {
// Initialize handle when needed
d.Lock()
if d.nlh == nil {
d.nlh = ns.NlHandle()
Method driver.Join
has 5 return statements (exceeds 4 allowed). Open
Open
func (d *driver) Join(ctx context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
ctx, span := otel.Tracer("").Start(ctx, "libnetwork.drivers.windows_overlay.Join", trace.WithAttributes(
attribute.String("nid", nid),
attribute.String("eid", eid),
attribute.String("sboxKey", sboxKey)))
Function NewClientWithOpts
has 5 return statements (exceeds 4 allowed). Open
Open
func NewClientWithOpts(ops ...Opt) (*Client, error) {
hostURL, err := ParseHostURL(DefaultDockerHost)
if err != nil {
return nil, err
}
Method Container.StatPath
has 5 return statements (exceeds 4 allowed). Open
Open
func (container *Container) StatPath(resolvedPath, absPath string) (stat *containertypes.PathStat, err error) {
if container.BaseFS == "" {
return nil, errors.New("StatPath: BaseFS of container " + container.ID + " is unexpectedly empty")
}
Method driver.DeleteEndpoint
has 5 return statements (exceeds 4 allowed). Open
Open
func (d *driver) DeleteEndpoint(nid, eid string) error {
if err := validateID(nid, eid); err != nil {
return err
}
Method windowsParser.ParseVolumesFrom
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *windowsParser) ParseVolumesFrom(spec string) (string, string, error) {
if len(spec) == 0 {
return "", "", fmt.Errorf("volumes-from specification cannot be an empty string")
}
Function makePluginAdapter
has 5 return statements (exceeds 4 allowed). Open
Open
func makePluginAdapter(p getter.CompatPlugin) (*volumeDriverAdapter, error) {
if pc, ok := p.(getter.PluginWithV1Client); ok {
return &volumeDriverAdapter{name: p.Name(), scopePath: p.ScopedPath, proxy: &volumeDriverProxy{pc.Client()}}, nil
}
Method ViewDB.GetByPrefix
has 5 return statements (exceeds 4 allowed). Open
Open
func (db *ViewDB) GetByPrefix(s string) (string, error) {
if s == "" {
return "", errdefs.InvalidParameter(errors.New("prefix can't be empty"))
}
iter, err := db.store.Txn(false).Get(memdbContainersTable, memdbIDIndexPrefix, s)
Method Client.SecretInspectWithRaw
has 5 return statements (exceeds 4 allowed). Open
Open
func (cli *Client) SecretInspectWithRaw(ctx context.Context, id string) (swarm.Secret, []byte, error) {
if err := cli.NewVersionError(ctx, "1.25", "secret inspect"); err != nil {
return swarm.Secret{}, nil, err
}
if id == "" {
Method Client.BuildCachePrune
has 5 return statements (exceeds 4 allowed). Open
Open
func (cli *Client) BuildCachePrune(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error) {
if err := cli.NewVersionError(ctx, "1.31", "build prune"); err != nil {
return nil, err
}
Method Service.Auth
has 5 return statements (exceeds 4 allowed). Open
Open
func (s *Service) Auth(ctx context.Context, authConfig *registry.AuthConfig, userAgent string) (status, token string, err error) {
// TODO Use ctx when searching for repositories
registryHostName := IndexHostname
if authConfig.ServerAddress != "" {
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{}
)
Function loginV2
has 5 return statements (exceeds 4 allowed). Open
Open
func loginV2(authConfig *registry.AuthConfig, endpoint APIEndpoint, userAgent string) (string, string, error) {
var (
endpointStr = strings.TrimRight(endpoint.URL.String(), "/") + "/v2/"
modifiers = Headers(userAgent, nil)
authTransport = transport.NewTransport(newTransport(endpoint.TLSConfig), modifiers...)