Showing 1,468 of 1,914 total issues
Function initializeStage
has 7 return statements (exceeds 4 allowed). Open
Open
func initializeStage(ctx context.Context, d dispatchRequest, cmd *instructions.Stage) error {
err := d.builder.imageProber.Reset(ctx)
if err != nil {
return err
}
Method Worker.GetRemotes
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (w *Worker) GetRemotes(ctx context.Context, ref cache.ImmutableRef, createIfNeeded bool, _ cacheconfig.RefConfig, all bool, s session.Group) ([]*solver.Remote, error) {
Method Backend.Build
has 7 return statements (exceeds 4 allowed). Open
Open
func (b *Backend) Build(ctx context.Context, config backend.BuildConfig) (string, error) {
options := config.Options
useBuildKit := options.Version == types.BuilderBuildKit
tags, err := sanitizeRepoAndTags(options.Tags)
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)
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)
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) {
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 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 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
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 client.NewContainer
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (c *client) NewContainer(_ context.Context, id string, spec *specs.Spec, shim string, runtimeOptions interface{}, opts ...containerd.NewContainerOpts) (libcontainerdtypes.Container, error) {
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
}
Avoid deeply nested control flow statements. Open
Open
if c.waitServe(ctx) {
go c.processEventStream(ctx, ns)
return
}
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 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)
}
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) {
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())
}
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
}
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) {