Showing 1,468 of 1,914 total issues
Function monitor
has 5 return statements (exceeds 4 allowed). Open
Open
func monitor(d *Daemon, c *container.Container, stop chan struct{}, probe probe) {
probeInterval := timeoutWithDefault(c.Config.Healthcheck.Interval, defaultProbeInterval)
startInterval := timeoutWithDefault(c.Config.Healthcheck.StartInterval, defaultStartInterval)
startPeriod := timeoutWithDefault(c.Config.Healthcheck.StartPeriod, defaultStartPeriod)
Function kernelSupportsRecursivelyReadOnly
has 5 return statements (exceeds 4 allowed). Open
Open
func kernelSupportsRecursivelyReadOnly() error {
fn := func() error {
tmpMnt, err := os.MkdirTemp("", "moby-detect-rro")
if err != nil {
return fmt.Errorf("failed to create a temp directory: %w", err)
Method task.Pause
has 5 return statements (exceeds 4 allowed). Open
Open
func (t *task) Pause(_ context.Context) error {
if t.ctr.ociSpec.Windows.HyperV == nil {
return cerrdefs.ErrNotImplemented
}
Function readJSON
has 5 return statements (exceeds 4 allowed). Open
Open
func readJSON(ctx context.Context, store content.Provider, desc ocispec.Descriptor, out interface{}) error {
data, err := content.ReadBlob(ctx, store, desc)
if err != nil {
err = errors.Wrapf(err, "failed to read config content")
if cerrdefs.IsNotFound(err) {
Function validateAddress
has 5 return statements (exceeds 4 allowed). Open
Open
func validateAddress(address string, subnet netip.Prefix, subnetFamily ipFamily) error {
if address == "" {
return nil
}
addr, err := netip.ParseAddr(address)
Function getUser
has 5 return statements (exceeds 4 allowed). Open
Open
func getUser(c *container.Container, username string) (specs.User, error) {
var usr specs.User
passwdPath, err := resourcePath(c, user.GetPasswdPath)
if err != nil {
return usr, err
Function newROLayerForImage
has 5 return statements (exceeds 4 allowed). Open
Open
func newROLayerForImage(ctx context.Context, imgDesc *ocispec.Descriptor, i *ImageService, platform *ocispec.Platform) (builder.ROLayer, error) {
if imgDesc == nil {
return nil, fmt.Errorf("can't make an RO layer for a nil image :'(")
}
Method rolayer.NewRWLayer
has 5 return statements (exceeds 4 allowed). Open
Open
func (rl *rolayer) NewRWLayer() (_ builder.RWLayer, outErr error) {
snapshotter := rl.c.SnapshotService(rl.snapshotter)
key := stringid.GenerateRandomID()
Method Daemon.ContainerTop
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func (daemon *Daemon) ContainerTop(name string, psArgs string) (*container.ContainerTopOKBody, error) {
if psArgs == "" {
psArgs = "-ef"
}
- 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.ImageInspect
has 5 return statements (exceeds 4 allowed). Open
Open
func (i *ImageService) ImageInspect(ctx context.Context, refOrID string, _ backend.ImageInspectOpts) (*imagetypes.InspectResponse, error) {
img, err := i.GetImage(ctx, refOrID, backend.GetImageOpts{})
if err != nil {
return nil, err
}
Function chownWithCaps
has 5 return statements (exceeds 4 allowed). Open
Open
func chownWithCaps(path string, uid int, gid int) error {
xattrKeys, err := sysx.LListxattr(path)
if err != nil {
return err
}
Method containerConfig.setTask
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *containerConfig) setTask(t *api.Task, node *api.NodeDescription) error {
if t.Spec.GetContainer() == nil && t.Spec.GetAttachment() == nil {
return exec.ErrRuntimeUnsupported
}
Method ImageService.ImageInspect
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func (i *ImageService) ImageInspect(ctx context.Context, refOrID string, _ backend.ImageInspectOpts) (*imagetypes.InspectResponse, error) {
img, err := i.GetImage(ctx, refOrID, backend.GetImageOpts{})
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 Controller.Start
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *Controller) Start(ctx context.Context) error {
p.logger.Debug("Start")
pl, err := p.backend.Get(p.pluginID)
if err != nil {
Method Controller.Remove
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *Controller) Remove(ctx context.Context) error {
p.logger.Debug("Remove")
pl, err := p.backend.Get(p.pluginID)
if err != nil {
Method ImageService.ImagesPrune
has 5 return statements (exceeds 4 allowed). Open
Open
func (i *ImageService) ImagesPrune(ctx context.Context, fltrs filters.Args) (*image.PruneReport, error) {
if !i.pruneRunning.CompareAndSwap(false, true) {
return nil, errPruneRunning
}
defer i.pruneRunning.Store(false)
Method Controller.Wait
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *Controller) Wait(ctx context.Context) error {
p.logger.Debug("Wait")
pl, err := p.backend.Get(p.pluginID)
if err != nil {
Method controller.Remove
has 5 return statements (exceeds 4 allowed). Open
Open
func (r *controller) Remove(ctx context.Context) error {
if err := r.checkClosed(); err != nil {
return err
}
Function convertSelector
has 5 return statements (exceeds 4 allowed). Open
Open
func convertSelector(ctx context.Context, cc swarmapi.ControlClient, selector *backend.LogSelector) (*swarmapi.LogSelector, error) {
// don't rely on swarmkit to resolve IDs, do it ourselves
swarmSelector := &swarmapi.LogSelector{}
for _, s := range selector.Services {
service, err := getService(ctx, cc, s, false)
Function validateDefaultAddrPool
has 5 return statements (exceeds 4 allowed). Open
Open
func validateDefaultAddrPool(defaultAddrPool []string, size uint32) error {
if defaultAddrPool == nil {
// defaultAddrPool is not defined
return nil
}