Showing 1,885 of 1,885 total issues
Method ImageService.manifestMatchesPlatform
has 5 return statements (exceeds 4 allowed). Open
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
Function parseDefaultRuntimeVersion
has 5 return statements (exceeds 4 allowed). Open
Open
func parseDefaultRuntimeVersion(rts *runtimes) (runtime, version, commit string, err error) {
shim, opts, err := rts.Get(rts.Default)
if err != nil {
return "", "", "", err
}
Method Daemon.containerExtractToDir
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
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 ImageService.ImageHistory
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func (i *ImageService) ImageHistory(ctx context.Context, name string) ([]*image.HistoryResponseItem, error) {
start := time.Now()
img, err := i.GetImage(ctx, name, backend.GetImageOpts{})
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
Function ValidateMinAPIVersion
has 5 return statements (exceeds 4 allowed). Open
Open
func ValidateMinAPIVersion(ver string) error {
if ver == "" {
return errors.New(`value is empty`)
}
if strings.EqualFold(ver[0:1], "v") {
Method Daemon.getNetworkedContainer
has 5 return statements (exceeds 4 allowed). Open
Open
func (daemon *Daemon) getNetworkedContainer(containerID, connectedContainerID string) (*container.Container, error) {
nc, err := daemon.GetContainer(connectedContainerID)
if err != nil {
return nil, err
}
Function getUserFromContainerd
has 5 return statements (exceeds 4 allowed). Open
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
}
Method cdiHandler.injectCDIDevices
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *cdiHandler) injectCDIDevices(s *specs.Spec, dev *deviceInstance) error {
if dev.req.Count != 0 {
return errdefs.InvalidParameter(errors.New("unexpected count in CDI device request"))
}
if len(dev.req.Options) > 0 {
Function GetTotalUsedFds
has 5 return statements (exceeds 4 allowed). Open
Open
func GetTotalUsedFds(ctx context.Context) int {
ctx, span := tracing.StartSpan(ctx, "GetTotalUsedFds")
defer span.End()
name := fmt.Sprintf("/proc/%d/fd", os.Getpid())
Method atomicFileWriter.Close
has 5 return statements (exceeds 4 allowed). Open
Open
func (w *atomicFileWriter) Close() (retErr error) {
defer func() {
if retErr != nil || w.writeErr != nil {
os.Remove(w.f.Name())
}
Function toRootless
has 5 return statements (exceeds 4 allowed). Open
Open
func toRootless(spec *specs.Spec, v2Controllers []string, currentOOMScoreAdj int) error {
if len(v2Controllers) == 0 {
if spec.Linux != nil {
// Remove cgroup settings.
spec.Linux.Resources = nil
Method layerStore.initMount
has 5 return statements (exceeds 4 allowed). Open
Open
func (ls *layerStore) initMount(graphID, parent, mountLabel string, initFunc MountInit, storageOpt map[string]string) (string, error) {
// Use "<graph-id>-init" to maintain compatibility with graph drivers
// which are expecting this layer with this special name. If all
// graph drivers can be updated to not rely on knowing about this layer
// then the initID should be randomly generated.
Function parseSubidFile
has 5 return statements (exceeds 4 allowed). Open
Open
func parseSubidFile(path, username string) (ranges, error) {
var rangeList ranges
subidFile, err := os.Open(path)
if err != nil {
Method scanner.Scan
has 5 return statements (exceeds 4 allowed). Open
Open
func (s *scanner) Scan(ctx context.Context) bool {
if s.err != nil {
return false
}
Function Zombie
has 5 return statements (exceeds 4 allowed). Open
Open
func Zombie(pid int) (bool, error) {
if pid < 1 {
return false, nil
}
data, err := os.ReadFile(fmt.Sprintf("/proc/%d/stat", pid))
Method layerStore.ChecksumForGraphID
has 5 return statements (exceeds 4 allowed). Open
Open
func (ls *layerStore) ChecksumForGraphID(id, parent, newTarDataPath string) (diffID DiffID, size int64, err error) {
rawarchive, err := ls.driver.Diff(id, parent)
if err != nil {
return
}
Function doPack
has 5 return statements (exceeds 4 allowed). Open
Open
func doPack(relSrc, root string, options *archive.TarOptions) (io.ReadCloser, error) {
optionsR, optionsW, err := os.Pipe()
if err != nil {
return nil, err
}
Function doUnpack
has 5 return statements (exceeds 4 allowed). Open
Open
func doUnpack(decompressedArchive io.Reader, relDest, root string, options *archive.TarOptions) error {
optionsR, optionsW, err := os.Pipe()
if err != nil {
return err
}
Function StickRuntimeDirContents
has 5 return statements (exceeds 4 allowed). Open
Open
func StickRuntimeDirContents(files []string) ([]string, error) {
runtimeDir, err := GetRuntimeDir()
if err != nil {
// ignore error if runtimeDir is empty
return nil, nil
Function RebaseArchiveEntries
has 5 return statements (exceeds 4 allowed). Open
Open
func RebaseArchiveEntries(srcContent io.Reader, oldBase, newBase string) io.ReadCloser {
if oldBase == string(os.PathSeparator) {
// If oldBase specifies the root directory, use an empty string as
// oldBase instead so that newBase doesn't replace the path separator
// that all paths will start with.