Showing 1,468 of 1,914 total issues
Method Daemon.setWindowsCredentialSpec
has 9 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) setWindowsCredentialSpec(c *container.Container, s *specs.Spec) error {
if c.HostConfig == nil || c.HostConfig.SecurityOpt == nil {
return nil
}
Method Daemon.ContainersPrune
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func (daemon *Daemon) ContainersPrune(ctx context.Context, pruneFilters filters.Args) (*container.PruneReport, error) {
if !daemon.pruneRunning.CompareAndSwap(false, true) {
return nil, errPruneRunning
}
defer daemon.pruneRunning.Store(false)
- 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.logNodeEvent
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func (daemon *Daemon) logNodeEvent(action swarmapi.WatchActionKind, node *swarmapi.Node, oldNode *swarmapi.Node) {
name := node.Spec.Annotations.Name
if name == "" && node.Description != nil {
name = node.Description.Hostname
}
- 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.CommitImage
has 9 return statements (exceeds 4 allowed). Open
func (i *ImageService) CommitImage(ctx context.Context, c backend.CommitConfig) (image.ID, error) {
if err := ctx.Err(); err != nil {
return "", err
}
Function readFrozenImageList
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func readFrozenImageList(ctx context.Context, dockerfilePath string, images []string) (map[string]string, error) {
f, err := os.Open(dockerfilePath)
if err != nil {
return nil, errors.Wrap(err, "error reading dockerfile")
}
- 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.CreateImageFromContainer
has 9 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) CreateImageFromContainer(ctx context.Context, name string, c *backend.CreateImageConfig) (string, error) {
start := time.Now()
container, err := daemon.GetContainer(name)
if err != nil {
Method layerStore.registerWithDescriptor
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func (ls *layerStore) registerWithDescriptor(ts io.Reader, parent ChainID, descriptor distribution.Descriptor) (Layer, error) {
// cErr is used to hold the error which will always trigger
// cleanup of creates sources but may not be an error returned
// to the caller (already exists).
var cErr error
- 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 decodeContainerConfig
has 9 return statements (exceeds 4 allowed). Open
func decodeContainerConfig(src io.Reader, si *sysinfo.SysInfo) (*container.Config, *container.HostConfig, *network.NetworkingConfig, error) {
var w container.CreateRequest
if err := loadJSON(src, &w); err != nil {
return nil, nil, nil, err
}
Method walker.walk
has 9 return statements (exceeds 4 allowed). Open
func (w *walker) walk(path string, i1, i2 os.FileInfo) (err error) {
// Register these nodes with the return trees, unless we're still at the
// (already-created) roots:
if path != "/" {
if err := walkchunk(path, i1, w.dir1, w.root1); err != nil {
Method layerStore.registerWithDescriptor
has 9 return statements (exceeds 4 allowed). Open
func (ls *layerStore) registerWithDescriptor(ts io.Reader, parent ChainID, descriptor distribution.Descriptor) (Layer, error) {
// cErr is used to hold the error which will always trigger
// cleanup of creates sources but may not be an error returned
// to the caller (already exists).
var cErr error
Function validateNetContainerMode
has 9 return statements (exceeds 4 allowed). Open
func validateNetContainerMode(c *container.Config, hc *container.HostConfig) error {
// FIXME(thaJeztah): a network named "container" (without colon) is not seen as "container-mode" network.
if string(hc.NetworkMode) != "container" && !hc.NetworkMode.IsContainer() {
return nil
}
Method layerStore.RegisterByGraphID
has 9 return statements (exceeds 4 allowed). Open
func (ls *layerStore) RegisterByGraphID(graphID string, parent ChainID, diffID DiffID, tarDataFile string, size int64) (Layer, error) {
// err is used to hold the error which will always trigger
// cleanup of creates sources but may not be an error returned
// to the caller (already exists).
var err error
Method Manager.Upgrade
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
func (pm *Manager) Upgrade(ctx context.Context, ref reference.Named, name string, metaHeader http.Header, authConfig *registry.AuthConfig, privileges types.PluginPrivileges, outStream io.Writer) error {
Method Manager.Upgrade
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
func (pm *Manager) Upgrade(ctx context.Context, ref reference.Named, name string, metaHeader http.Header, authConfig *registry.AuthConfig, privileges types.PluginPrivileges, outStream io.Writer) (err error) {
Function New
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
func New(ctx context.Context, rootDir string, cli *containerd.Client, ns string, exitHandler ExitHandler, shim string, shimOpts interface{}) (*Executor, error) {
Function ReplaceContainer
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
func ReplaceContainer(ctx context.Context, client types.Client, id string, spec *specs.Spec, shim string, runtimeOptions interface{}, opts ...containerd.NewContainerOpts) (types.Container, error) {
Method store.restore
has 8 return statements (exceeds 4 allowed). Open
func (is *store) restore() error {
// As the code below is run when restoring all images (which can be "many"),
// constructing the "log.G(ctx).WithFields" is deliberately not "DRY", as the
// logger is only used for error-cases, and we don't want to do allocations
// if we don't need it. The "f" type alias is here is just for convenience,
Method ImageCache.GetCache
has 8 return statements (exceeds 4 allowed). Open
func (ic *ImageCache) GetCache(parentID string, cfg *containertypes.Config, platform ocispec.Platform) (string, error) {
imgID, err := ic.localImageCache.GetCache(parentID, cfg, platform)
if err != nil {
return "", err
}
Function setupSeccomp
has 8 return statements (exceeds 4 allowed). Open
func setupSeccomp(config *Seccomp, rs *specs.Spec) (*specs.LinuxSeccomp, error) {
if config == nil {
return nil, nil
}
Method Manager.Upgrade
has 8 return statements (exceeds 4 allowed). Open
func (pm *Manager) Upgrade(ctx context.Context, ref reference.Named, name string, metaHeader http.Header, authConfig *registry.AuthConfig, privileges types.PluginPrivileges, outStream io.Writer) (err error) {
p, err := pm.config.Store.GetV2Plugin(name)
if err != nil {
return err
}