Showing 1,468 of 1,914 total issues
Method ImageManifest.IsPseudoImage
has 7 return statements (exceeds 4 allowed). Open
Open
func (im *ImageManifest) IsPseudoImage(ctx context.Context) (bool, error) {
if im.IsAttestation() {
return true, nil
}
Method ImageService.PullImage
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (i *ImageService) PullImage(ctx context.Context, baseRef reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registrytypes.AuthConfig, outStream io.Writer) (retErr error) {
Method ImageService.pullForBuilder
has 7 return statements (exceeds 4 allowed). Open
Open
func (i *ImageService) pullForBuilder(ctx context.Context, name string, authConfigs map[string]registry.AuthConfig, output io.Writer, platform *ocispec.Platform) (*ocispec.Descriptor, error) {
ref, err := reference.ParseNormalizedNamed(name)
if err != nil {
return nil, err
}
Method Cluster.resolveSystemAddrViaSubnetCheck
has 7 return statements (exceeds 4 allowed). Open
Open
func (c *Cluster) resolveSystemAddrViaSubnetCheck() (net.IP, error) {
// Use the system's only IP address, or fail if there are
// multiple addresses to choose from. Skip interfaces which
// are managed by docker via subnet check.
interfaces, err := net.Interfaces()
Function newContainerAdapter
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func newContainerAdapter(b executorpkg.Backend, i executorpkg.ImageBackend, v executorpkg.VolumeBackend, task *api.Task, node *api.NodeDescription, dependencies exec.DependencyGetter) (*containerAdapter, error) {
Function resolveInterfaceAddr
has 7 return statements (exceeds 4 allowed). Open
Open
func resolveInterfaceAddr(specifiedInterface string) (net.IP, error) {
// Use a specific interface's IP address.
intf, err := net.InterfaceByName(specifiedInterface)
if err != nil {
return nil, errNoSuchInterface
Avoid deeply nested control flow statements. Open
Open
} else if ctnr.State.ExitCode != 0 {
return &exitError{code: ctnr.State.ExitCode, cause: healthErr}
}
Function writeContentsForImage
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func writeContentsForImage(ctx context.Context, snName string, cs content.Store,
newConfig imagespec.DockerOCIImage, layers []ocispec.Descriptor,
containerConfig container.Config,
Method ImageService.verifyImagesProvidePlatform
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (i *ImageService) verifyImagesProvidePlatform(ctx context.Context, imgs []containerdimages.Image, platform ocispec.Platform, pm platforms.Matcher) error {
if len(imgs) == 0 {
return errdefs.NotFound(fmt.Errorf("no images providing the requested platform %s found", platforms.FormatAll(platform)))
}
var incompleteImgs []string
- 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 newController
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func newController(b executorpkg.Backend, i executorpkg.ImageBackend, v executorpkg.VolumeBackend, task *api.Task, node *api.NodeDescription, dependencies exec.DependencyGetter) (*controller, error) {
Function newNetworkAttacherController
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func newNetworkAttacherController(b executorpkg.Backend, i executorpkg.ImageBackend, v executorpkg.VolumeBackend, task *api.Task, node *api.NodeDescription, dependencies exec.DependencyGetter) (*networkAttacherController, error) {
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
} else if !allTags {
if tagged, ok := repoRef.(reference.Tagged); ok {
if tag == "" {
tag = tagged.Tag()
} else if tag != tagged.Tag() {
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 ImageService.pullTag
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (i *ImageService) pullTag(ctx context.Context, ref reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registrytypes.AuthConfig, out progress.Output) error {
Function initClusterSpec
has 7 return statements (exceeds 4 allowed). Open
Open
func initClusterSpec(node *swarmnode.Node, spec types.Spec) error {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
for conn := range node.ListenControlSocket(ctx) {
if ctx.Err() != nil {
Function ValidateLogOpt
has 7 return statements (exceeds 4 allowed). Open
Open
func ValidateLogOpt(cfg map[string]string) error {
address, err := parseAddress(cfg["gelf-address"])
if err != nil {
return err
}
Avoid deeply nested control flow statements. Open
Open
if logErr := c.dst.Log(msg); logErr != nil {
logDriverError(c.dst.Name(), string(msg.Line), logErr)
}
Method Daemon.newContainer
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (daemon *Daemon) newContainer(name string, operatingSystem string, config *containertypes.Config, hostConfig *containertypes.HostConfig, imgID image.ID, managed bool) (*container.Container, error) {
Avoid deeply nested control flow statements. Open
Open
if jsonEvent, err := json.Marshal(messages[j]); err != nil {
log.G(ctx).Error(err)
} else {
log.G(ctx).Error(fmt.Errorf("Failed to send a message '%s'", string(jsonEvent)))
}