Showing 1,468 of 1,914 total issues
Method Cluster.GetService
has 5 return statements (exceeds 4 allowed). Open
func (c *Cluster) GetService(input string, insertDefaults bool) (swarm.Service, error) {
var service *swarmapi.Service
if err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
s, err := getService(ctx, state.controlClient, input, insertDefaults)
if err != nil {
Method executor.Describe
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) {
info, err := e.backend.SystemInfo(ctx)
if err != nil {
return nil, err
}
- 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 Cluster.CreateNetwork
has 5 return statements (exceeds 4 allowed). Open
func (c *Cluster) CreateNetwork(s network.CreateRequest) (string, error) {
if networkSettings.IsPredefined(s.Name) {
err := notAllowedError(fmt.Sprintf("%s is a pre-defined network and cannot be created", s.Name))
return "", errors.WithStack(err)
}
Method Cluster.Info
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (c *Cluster) Info(ctx context.Context) types.Info {
info := types.Info{
NodeAddr: c.GetAdvertiseAddress(),
}
c.mu.RLock()
- 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 ImageService.PushImage
has 5 return statements (exceeds 4 allowed). Open
func (i *ImageService) PushImage(ctx context.Context, sourceRef reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) (retErr error) {
start := time.Now()
defer func() {
if retErr == nil {
dimages.ImageActions.WithValues("push").UpdateSince(start)
Method Cluster.AttachNetwork
has 5 return statements (exceeds 4 allowed). Open
func (c *Cluster) AttachNetwork(target string, containerID string, addresses []string) (*network.NetworkingConfig, error) {
aKey := attacherKey(target, containerID)
c.mu.Lock()
state := c.currentNodeState()
if state.swarmNode == nil || state.swarmNode.Agent() == nil {
Method follow.nextPos
has 5 return statements (exceeds 4 allowed). Open
func (fl *follow) nextPos(ctx context.Context, current logPos) (next logPos, ok bool) {
var st logReadState
select {
case <-ctx.Done():
return current, false
Method reader.wait
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (r *reader) wait(ctx context.Context) (bool, error) {
deadline := r.drainDeadline
if d, ok := ctx.Deadline(); ok && d.Before(deadline) {
deadline = d
}
- 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 getNode
has 5 return statements (exceeds 4 allowed). Open
func getNode(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Node, error) {
// GetNode to match via full ID.
if rg, err := c.GetNode(ctx, &swarmapi.GetNodeRequest{NodeID: input}); err == nil {
return rg.Node, nil
}
Function getSecret
has 5 return statements (exceeds 4 allowed). Open
func getSecret(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Secret, error) {
// attempt to lookup secret by full ID
if rg, err := c.GetSecret(ctx, &swarmapi.GetSecretRequest{SecretID: input}); err == nil {
return rg.Secret, nil
}
Method Copier.copySrc
has 5 return statements (exceeds 4 allowed). Open
func (c *Copier) copySrc(name string, src io.Reader) {
defer c.copyJobs.Done()
bufSize := defaultBufSize
if sizedLogger, ok := c.dst.(SizedLogger); ok {
Method Cluster.CreateVolume
has 5 return statements (exceeds 4 allowed). Open
func (c *Cluster) CreateVolume(v volumetypes.CreateOptions) (*volumetypes.Volume, error) {
var resp *swarmapi.CreateVolumeResponse
if err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
volumeSpec := convert.VolumeCreateToGRPC(&v)
Function getConfig
has 5 return statements (exceeds 4 allowed). Open
func getConfig(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Config, error) {
// attempt to lookup config by full ID
if rg, err := c.GetConfig(ctx, &swarmapi.GetConfigRequest{ConfigID: input}); err == nil {
return rg.Config, nil
}
Method Daemon.ContainerStart
has 5 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) ContainerStart(ctx context.Context, name string, checkpoint string, checkpointDir string) error {
daemonCfg := daemon.config()
if checkpoint != "" && !daemonCfg.Experimental {
return errdefs.InvalidParameter(errors.New("checkpoint is only supported in experimental mode"))
}
Method Daemon.getActiveContainer
has 5 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) getActiveContainer(name string) (*container.Container, error) {
ctr, err := daemon.GetContainer(name)
if err != nil {
return nil, err
}
Function getNetwork
has 5 return statements (exceeds 4 allowed). Open
func getNetwork(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Network, error) {
// GetNetwork to match via full ID.
if rg, err := c.GetNetwork(ctx, &swarmapi.GetNetworkRequest{NetworkID: input}); err == nil {
return rg.Network, nil
}
Function unlink
has 5 return statements (exceeds 4 allowed). Open
func unlink(name string) error {
// Rename the file before deleting it so that the original name is freed
// up to be reused, even while there are still open FILE_SHARE_DELETE
// file handles. Emulate POSIX unlink() semantics, essentially.
name, err := filepath.Abs(name)
Method Daemon.containerPause
has 5 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) containerPause(container *container.Container) error {
container.Lock()
defer container.Unlock()
// We cannot Pause the container which is not running
Method Daemon.reserveName
has 5 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) reserveName(id, name string) (string, error) {
if !validContainerNamePattern.MatchString(strings.TrimPrefix(name, "/")) {
return "", errdefs.InvalidParameter(errors.Errorf("Invalid container name (%s), only %s are allowed", name, validContainerNameChars))
}
if name[0] != '/' {
Method Cluster.GetUnlockKey
has 5 return statements (exceeds 4 allowed). Open
func (c *Cluster) GetUnlockKey() (string, error) {
var resp *swarmapi.GetUnlockKeyResponse
if err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
client := swarmapi.NewCAClient(state.grpcConn)