Showing 1,468 of 1,914 total issues
Method ImageService.createDiff
has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring. Open
func (i *ImageService) createDiff(ctx context.Context, name string, sn snapshots.Snapshotter, cs content.Store, comparer diff.Comparer) (*ocispec.Descriptor, digest.Digest, error) {
info, err := sn.Stat(ctx, name)
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 layerDescriptor.Download
has 106 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (ld *layerDescriptor) Download(ctx context.Context, progressOutput progress.Output) (io.ReadCloser, int64, error) {
log.G(ctx).Debugf("pulling blob %q", ld.digest)
var (
err error
Method imageExporterInstance.Export
has 106 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (e *imageExporterInstance) Export(ctx context.Context, inp *exporter.Source, inlineCache exptypes.InlineCache, sessionID string) (map[string]string, exporter.DescriptorReference, error) {
if len(inp.Refs) > 1 {
return nil, nil, fmt.Errorf("exporting multiple references to image store is currently unsupported")
}
Method Daemon.ContainerLogs
has 106 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (daemon *Daemon) ContainerLogs(ctx context.Context, containerName string, config *containertypes.LogsOptions) (messages <-chan *backend.LogMessage, isTTY bool, retErr error) {
ctx, span := tracing.StartSpan(ctx, "daemon.ContainerLogs")
defer func() {
span.SetStatus(retErr)
span.End()
File sandbox.go
has 550 lines of code (exceeds 500 allowed). Consider refactoring. Open
package libnetwork
import (
"context"
"encoding/json"
Method Daemon.createSpec
has 105 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (daemon *Daemon) createSpec(ctx context.Context, daemonCfg *configStore, c *container.Container, mounts []container.Mount) (*specs.Spec, error) {
img, err := daemon.imageService.GetImage(ctx, string(c.ImageID), backend.GetImageOpts{})
if err != nil {
return nil, err
}
Method driver.CreateNetwork
has 103 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error {
var (
networkName string
interfaceName string
staleNetworks []string
Method Daemon.createNetwork
has 103 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (daemon *Daemon) createNetwork(cfg *config.Config, create networktypes.CreateRequest, id string, agent bool) (*networktypes.CreateResponse, error) {
if network.IsPredefined(create.Name) {
return nil, PredefinedNetworkError(create.Name)
}
Method Endpoint.UnmarshalJSON
has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring. Open
func (ep *Endpoint) UnmarshalJSON(b []byte) (err error) {
ep.mu.Lock()
defer ep.mu.Unlock()
var epMap map[string]interface{}
- 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.pushRef
has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring. 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) {
leasedCtx, release, err := i.client.WithLease(ctx)
if err != nil {
return 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
Function buildCreateEndpointOptions
has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring. Open
func buildCreateEndpointOptions(c *container.Container, n *libnetwork.Network, epConfig *network.EndpointSettings, sb *libnetwork.Sandbox, daemonDNS []string) ([]libnetwork.EndpointOption, error) {
var createOptions []libnetwork.EndpointOption
genericOptions := make(options.Generic)
nwName := n.Name()
- 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.connectToNetwork
has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring. Open
func (daemon *Daemon) connectToNetwork(ctx context.Context, cfg *config.Config, ctr *container.Container, idOrName string, endpointConfig *network.EndpointSettings, updateSettings bool) (retErr error) {
containerName := strings.TrimPrefix(ctr.Name, "/")
ctx, span := otel.Tracer("").Start(ctx, "daemon.connectToNetwork", trace.WithAttributes(
attribute.String("container.ID", ctr.ID),
attribute.String("container.name", containerName),
- 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
File encryption.go
has 545 lines of code (exceeds 500 allowed). Consider refactoring. Open
//go:build linux
package overlay
import (
Method ImageService.pushRef
has 102 lines of code (exceeds 50 allowed). Consider refactoring. 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) {
leasedCtx, release, err := i.client.WithLease(ctx)
if err != nil {
return err
}
Method ImageService.resolveAllReferences
has 102 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (i *ImageService) resolveAllReferences(ctx context.Context, refOrID string) (*containerdimages.Image, []containerdimages.Image, error) {
parsed, err := reference.ParseAnyReference(refOrID)
if err != nil {
return nil, nil, errdefs.InvalidParameter(err)
}
Method ImageService.ImagesPrune
has 102 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (i *ImageService) ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*imagetypes.PruneReport, error) {
if !i.pruneRunning.CompareAndSwap(false, true) {
return nil, errPruneRunning
}
defer i.pruneRunning.Store(false)
Method Endpoint.UnmarshalJSON
has 101 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (ep *Endpoint) UnmarshalJSON(b []byte) (err error) {
ep.mu.Lock()
defer ep.mu.Unlock()
var epMap map[string]interface{}
Method Copier.copySrc
has 101 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (c *Copier) copySrc(name string, src io.Reader) {
defer c.copyJobs.Done()
bufSize := defaultBufSize
if sizedLogger, ok := c.dst.(SizedLogger); ok {
Method Controller.sandboxCleanup
has 100 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (c *Controller) sandboxCleanup(activeSandboxes map[string]interface{}) error {
sandboxStates, err := c.store.List(&sbState{c: c})
if err != nil {
if err == datastore.ErrKeyNotFound {
// It's normal for no sandboxes to be found. Just bail out.
Method GossipMessage.Unmarshal
has 100 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *GossipMessage) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx