Showing 1,468 of 1,914 total issues
Method ImageService.GetImage
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (i *ImageService) GetImage(ctx context.Context, refOrID string, options backend.GetImageOpts) (retImg *image.Image, retErr error) {
defer func() {
if retErr != nil || retImg == nil || options.Platform == nil {
return
}
- 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.GetImageAndReleasableLayer
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error) {
if refOrID == "" { // FROM scratch
if runtime.GOOS == "windows" {
return nil, nil, fmt.Errorf(`"FROM scratch" is not supported on Windows`)
}
- 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.releaseNetwork
has 5 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) releaseNetwork(ctx context.Context, ctr *container.Container) {
ctx = context.WithoutCancel(ctx)
start := time.Now()
// If live-restore is enabled, the daemon cleans up dead containers when it starts up. In that case, the
Method ImageService.ImageHistory
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (i *ImageService) ImageHistory(ctx context.Context, name string, platform *ocispec.Platform) ([]*image.HistoryResponseItem, error) {
start := time.Now()
img, err := i.GetImage(ctx, name, backend.GetImageOpts{Platform: platform})
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 Daemon.deleteNetwork
has 5 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) deleteNetwork(nw *libnetwork.Network, dynamic bool) error {
if network.IsPredefined(nw.Name()) && !dynamic {
err := fmt.Errorf("%s is a pre-defined network and cannot be removed", nw.Name())
return errdefs.Forbidden(err)
}
Method Daemon.containerExtractToDir
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (daemon *Daemon) containerExtractToDir(container *container.Container, path string, copyUIDGID, noOverwriteDirNonDir bool, content io.Reader) (err error) {
container.Lock()
defer container.Unlock()
// Make sure an online file-system operation is permitted.
- 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.containerStatPath
has 5 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) containerStatPath(container *container.Container, path string) (stat *containertypes.PathStat, err error) {
container.Lock()
defer container.Unlock()
// Make sure an online file-system operation is permitted.
Method Daemon.NetworksPrune
has 5 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) NetworksPrune(ctx context.Context, pruneFilters filters.Args) (*network.PruneReport, error) {
if !daemon.pruneRunning.CompareAndSwap(false, true) {
return nil, errPruneRunning
}
defer daemon.pruneRunning.Store(false)
Function updateJoinInfo
has 5 return statements (exceeds 4 allowed). Open
func updateJoinInfo(networkSettings *network.Settings, n *libnetwork.Network, ep *libnetwork.Endpoint) error {
if ep == nil {
return errors.New("invalid enppoint whhile building portmap info")
}
Method ImageService.GetLayerFolders
has 5 return statements (exceeds 4 allowed). Open
func (i *ImageService) GetLayerFolders(img *image.Image, rwLayer layer.RWLayer, containerID string) ([]string, error) {
folders := []string{}
rd := len(img.RootFS.DiffIDs)
for index := 1; index <= rd; index++ {
// FIXME: why does this mutate the RootFS?
Function getUntilFromPruneFilters
has 5 return statements (exceeds 4 allowed). Open
func getUntilFromPruneFilters(pruneFilters filters.Args) (time.Time, error) {
until := time.Time{}
if !pruneFilters.Contains("until") {
return until, nil
}
Function getEndpointPortMapInfo
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func getEndpointPortMapInfo(ep *libnetwork.Endpoint) (nat.PortMap, error) {
pm := nat.PortMap{}
driverInfo, err := ep.DriverInfo()
if err != nil {
return pm, 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 Daemon.updateNetwork
has 5 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) updateNetwork(cfg *config.Config, ctr *container.Container) error {
var (
start = time.Now()
ctrl = daemon.netController
sid = ctr.NetworkSettings.SandboxID
Method ImageService.manifestMatchesPlatform
has 5 return statements (exceeds 4 allowed). Open
func (i *ImageService) manifestMatchesPlatform(ctx context.Context, img *image.Image, platform ocispec.Platform) (bool, error) {
ls, err := i.leases.ListResources(ctx, leases.Lease{ID: imageKey(img.ID().String())})
if err != nil {
if cerrdefs.IsNotFound(err) {
return false, nil
Method Daemon.createSpecWindowsFields
has 5 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) createSpecWindowsFields(c *container.Container, s *specs.Spec, isHyperV bool) error {
s.Hostname = c.FullHostname()
if len(s.Process.Cwd) == 0 {
// We default to C:\ to workaround the oddity of the case that the
Function buildEndpointInfo
has 5 return statements (exceeds 4 allowed). Open
func buildEndpointInfo(networkSettings *network.Settings, n *libnetwork.Network, ep *libnetwork.Endpoint) error {
if ep == nil {
return errors.New("endpoint cannot be nil")
}
Method Daemon.getNetworkedContainer
has 5 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) getNetworkedContainer(containerID, connectedContainerID string) (*container.Container, error) {
nc, err := daemon.GetContainer(connectedContainerID)
if err != nil {
return nil, err
}
Function getSystemCPUUsage
has 5 return statements (exceeds 4 allowed). Open
func getSystemCPUUsage() (cpuUsage uint64, cpuNum uint32, err error) {
f, err := os.Open("/proc/stat")
if err != nil {
return 0, 0, err
}
Method Daemon.containerArchivePath
has 5 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) containerArchivePath(container *container.Container, path string) (content io.ReadCloser, stat *containertypes.PathStat, err error) {
container.Lock()
defer func() {
if err != nil {
Function getUserFromContainerd
has 5 return statements (exceeds 4 allowed). Open
func getUserFromContainerd(ctx context.Context, containerdCli *containerd.Client, ec *container.ExecConfig) (specs.User, error) {
ctr, err := containerdCli.LoadContainer(ctx, ec.Container.ID)
if err != nil {
return specs.User{}, err
}