Showing 1,904 of 1,904 total issues
Method imageRouter.postImagesPush
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (ir *imageRouter) postImagesPush(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
metaHeaders := map[string][]string{}
for k, v := range r.Header {
if strings.HasPrefix(k, "X-Meta-") {
metaHeaders[k] = v
- 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 containerRouter.postContainerExecStart
has 7 return statements (exceeds 4 allowed). Open
Open
func (s *containerRouter) postContainerExecStart(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
Method Daemon.cleanupMounts
has 7 return statements (exceeds 4 allowed). Open
Open
func (daemon *Daemon) cleanupMounts(cfg *config.Config) error {
if err := daemon.cleanupMountsByID(""); err != nil {
return err
}
Method cacheAdaptor.Get
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (c cacheAdaptor) Get(id image.ID) (*image.Image, error) {
ctx := context.TODO()
ref := id.String()
outImg, err := c.is.GetImage(ctx, id.String(), backend.GetImageOpts{})
- 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 Daemon.createContainerOSSpecificSettings
has 7 return statements (exceeds 4 allowed). Open
Open
func (daemon *Daemon) createContainerOSSpecificSettings(ctx context.Context, container *container.Container, config *containertypes.Config, hostConfig *containertypes.HostConfig) error {
if err := daemon.Mount(container); err != nil {
return err
}
defer daemon.Unmount(container)
Method ImageService.PushImage
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
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) {
Function findMissingMountable
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func findMissingMountable(ctx context.Context, store content.Store, queue *jobs,
target ocispec.Descriptor, targetRef reference.Named, limiter *semaphore.Weighted,
Method client.NewContainer
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (c *client) NewContainer(ctx context.Context, id string, ociSpec *specs.Spec, shim string, runtimeOptions interface{}, opts ...containerd.NewContainerOpts) (libcontainerdtypes.Container, error) {
Function saveArchive
has 7 return statements (exceeds 4 allowed). Open
Open
func saveArchive(ctx context.Context, cs content.Store, layerReader io.Reader) (digest.Digest, digest.Digest, string, error) {
// Wrap the reader in buffered reader to allow peeks.
p := pools.BufioReader32KPool
bufRd := p.Get(layerReader)
defer p.Put(bufRd)
Function findMissingMountable
has 7 return statements (exceeds 4 allowed). Open
Open
func findMissingMountable(ctx context.Context, store content.Store, queue *jobs,
target ocispec.Descriptor, targetRef reference.Named, limiter *semaphore.Weighted,
) (map[digest.Digest]distributionSource, error) {
mountableBlobs := map[digest.Digest]distributionSource{}
var mutex sync.Mutex
Avoid deeply nested control flow statements. Open
Open
if c.waitServe(ctx) {
go c.processEventStream(ctx, ns)
return
}
Method task.CreateCheckpoint
has 7 return statements (exceeds 4 allowed). Open
Open
func (t *task) CreateCheckpoint(ctx context.Context, checkpointDir string, exit bool) error {
img, err := t.Task.Checkpoint(ctx, t.ctr.getCheckpointOptions(exit))
if err != nil {
return wrapError(err)
}
Function ifaceAddrs
has 7 return statements (exceeds 4 allowed). Open
Open
func ifaceAddrs(linkName string) (v4, v6 []*net.IPNet, err error) {
nl := ns.NlHandle()
link, err := nl.LinkByName(linkName)
if err != nil {
if !errors.As(err, new(netlink.LinkNotFoundError)) {
Method ImageService.ImportImage
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (i *ImageService) ImportImage(ctx context.Context, ref reference.Named, platform *ocispec.Platform, msg string, layerReader io.Reader, changes []string) (image.ID, error) {
Method ImageService.applyDiffLayer
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (i *ImageService) applyDiffLayer(ctx context.Context, name string, containerID string, sn snapshots.Snapshotter, differ diff.Applier, diffDesc ocispec.Descriptor) (retErr error) {
Method client.newStdioPipes
has 7 return statements (exceeds 4 allowed). Open
Open
func (c *client) newStdioPipes(fifos *cio.FIFOSet) (_ *stdioPipes, err error) {
p := &stdioPipes{}
if fifos.Stdin != "" {
c.logger.WithField("stdin", fifos.Stdin).Debug("listen")
l, err := winio.ListenPipe(fifos.Stdin, nil)
Method Daemon.populateVolume
has 7 return statements (exceeds 4 allowed). Open
Open
func (daemon *Daemon) populateVolume(ctx context.Context, c *container.Container, mnt *volumemounts.MountPoint) error {
ctrDestPath, err := c.GetResourcePath(mnt.Destination)
if err != nil {
return err
}
Function setExitCodeFromError
has 7 return statements (exceeds 4 allowed). Open
Open
func setExitCodeFromError(setExitCode func(exitStatus), err error) error {
if err == nil {
return nil
}
errDesc := status.Convert(err).Message()
Method ImageService.pushRef
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (i *ImageService) pushRef(ctx context.Context, targetRef reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, out progress.Output) (retErr error) {
Avoid deeply nested control flow statements. Open
Open
if err := unmount(mnt); err != nil {
log.G(context.TODO()).Error(err)
errs = append(errs, err.Error())
}