Showing 1,468 of 1,914 total issues
Method Daemon.initializeNetworkingPaths
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (daemon *Daemon) initializeNetworkingPaths(ctr *container.Container, nc *container.Container) error {
if nc.HostConfig.Isolation.IsHyperV() {
return fmt.Errorf("sharing of hyperv containers network is not supported")
}
- 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.setupConfigDir
has 7 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) setupConfigDir(ctr *container.Container) (setupErr error) {
if len(ctr.ConfigReferences) == 0 {
return nil
}
Method Daemon.setupContainerDirs
has 7 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) setupContainerDirs(c *container.Container) ([]container.Mount, error) {
// Note, unlike Unix, we do NOT call into SetupWorkingDirectory as
// this is done in VMCompute. Further, we couldn't do it for Hyper-V
// containers anyway.
if err := daemon.setupSecretDir(c); err != nil {
Method Daemon.foldFilter
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (daemon *Daemon) foldFilter(ctx context.Context, view *container.View, config *containertypes.ListOptions) (*listContext, error) {
psFilters := config.Filters
var filtExited []int
- 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.findAndAttachNetwork
has 7 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) findAndAttachNetwork(ctr *container.Container, idOrName string, epConfig *networktypes.EndpointSettings) (*libnetwork.Network, *networktypes.NetworkingConfig, error) {
id := getNetworkID(idOrName, epConfig)
n, err := daemon.FindNetwork(id)
if err != nil {
Method NaiveDiffDriver.Diff
has 7 return statements (exceeds 4 allowed). Open
func (gdw *NaiveDiffDriver) Diff(id, parent string) (arch io.ReadCloser, err error) {
startTime := time.Now()
driver := gdw.ProtoDriver
layerRootFs, err := driver.Get(id, "")
Avoid deeply nested control flow statements. Open
if retryCount >= 5 {
return nil, nil, fmt.Errorf("could not find network %s after successful attachment", idOrName)
}
Method ImageService.ImportImage
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func (i *ImageService) ImportImage(ctx context.Context, newRef reference.Named, platform *ocispec.Platform, msg string, layerReader io.Reader, changes []string) (image.ID, error) {
Method ImageService.PullImage
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func (i *ImageService) PullImage(ctx context.Context, ref reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error {
Method ImageService.pullImageWithReference
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func (i *ImageService) pullImageWithReference(ctx context.Context, ref reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error {
Method Daemon.DisconnectFromNetwork
has 7 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) DisconnectFromNetwork(ctx context.Context, ctr *container.Container, networkName string, force bool) error {
n, err := daemon.FindNetwork(networkName)
ctr.Lock()
defer ctr.Unlock()
Method Daemon.ContainerTop
has 7 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) ContainerTop(name string, psArgs string) (*containertypes.ContainerTopOKBody, error) {
// It's not at all an equivalent to linux 'ps' on Windows
if psArgs != "" {
return nil, errors.New("Windows does not support arguments to top")
}
Method ImageService.checkImageDeleteConflict
has 7 return statements (exceeds 4 allowed). Open
func (i *ImageService) checkImageDeleteConflict(imgID image.ID, mask conflictType) *imageDeleteConflict {
// Check if the image has any descendant images.
if mask&conflictDependentChild != 0 && len(i.imageStore.Children(imgID)) > 0 {
return &imageDeleteConflict{
hard: true,
Method Daemon.createSpec
has 7 return statements (exceeds 4 allowed). 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 Daemon.connectToNetwork
has 6 arguments (exceeds 4 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) {
Method Daemon.clusterNetworksPrune
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (daemon *Daemon) clusterNetworksPrune(ctx context.Context, pruneFilters filters.Args) (*network.PruneReport, error) {
rep := &network.PruneReport{}
until, _ := getUntilFromPruneFilters(pruneFilters)
- 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.buildSandboxOptions
has 7 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) buildSandboxOptions(cfg *config.Config, ctr *container.Container) ([]libnetwork.SandboxOption, error) {
var sboxOptions []libnetwork.SandboxOption
sboxOptions = append(sboxOptions, libnetwork.OptionHostname(ctr.Config.Hostname), libnetwork.OptionDomainname(ctr.Config.Domainname))
if ctr.HostConfig.NetworkMode.IsHost() {
Method ImageService.PushImage
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func (i *ImageService) PushImage(ctx context.Context, ref reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error {
Avoid deeply nested control flow statements. Open
if _, err := i.removeImageRef(repoRef); err != nil {
return records, err
}
Function mkdirall
has 7 return statements (exceeds 4 allowed). Open
func mkdirall(path string, perm *windows.SecurityAttributes) error {
if volumePath.MatchString(path) {
return nil
}