Showing 1,412 of 1,855 total issues
Function unlink
has 5 return statements (exceeds 4 allowed). Open
Open
func unlink(name string) error {
// Rename the file before deleting it so that the original name is freed
// up to be reused, even while there are still open FILE_SHARE_DELETE
// file handles. Emulate POSIX unlink() semantics, essentially.
name, err := filepath.Abs(name)
Method Daemon.reserveName
has 5 return statements (exceeds 4 allowed). Open
Open
func (daemon *Daemon) reserveName(id, name string) (string, error) {
if !validContainerNamePattern.MatchString(strings.TrimPrefix(name, "/")) {
return "", errdefs.InvalidParameter(errors.Errorf("Invalid container name (%s), only %s are allowed", name, validContainerNameChars))
}
if name[0] != '/' {
Method Daemon.ContainerStart
has 5 return statements (exceeds 4 allowed). Open
Open
func (daemon *Daemon) ContainerStart(ctx context.Context, name string, checkpoint string, checkpointDir string) error {
daemonCfg := daemon.config()
if checkpoint != "" && !daemonCfg.Experimental {
return errdefs.InvalidParameter(errors.New("checkpoint is only supported in experimental mode"))
}
Function validateContainerConfig
has 5 return statements (exceeds 4 allowed). Open
Open
func validateContainerConfig(config *containertypes.Config) error {
if config == nil {
return nil
}
if err := translateWorkingDir(config); err != nil {
Method Daemon.ContainerKill
has 5 return statements (exceeds 4 allowed). Open
Open
func (daemon *Daemon) ContainerKill(name, stopSignal string) error {
var (
err error
sig = syscall.SIGKILL
)
Function buildEndpointInfo
has 5 return statements (exceeds 4 allowed). Open
Open
func buildEndpointInfo(networkSettings *internalnetwork.Settings, n *libnetwork.Network, ep *libnetwork.Endpoint) error {
if ep == nil {
return errors.New("endpoint cannot be nil")
}
Function New
has 5 return statements (exceeds 4 allowed). Open
Open
func New(info logger.Info) (logger.Logger, error) {
initGCP()
var project string
if projectID != "" {
Function copyRegular
has 5 return statements (exceeds 4 allowed). Open
Open
func copyRegular(srcPath, dstPath string, fileinfo os.FileInfo, copyWithFileRange, copyWithFileClone *bool) error {
srcFile, err := os.Open(srcPath)
if err != nil {
return err
}
Function updateJoinInfo
has 5 return statements (exceeds 4 allowed). Open
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")
}
Function validateEndpointSettings
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func validateEndpointSettings(nw *libnetwork.Network, nwName string, epConfig *networktypes.EndpointSettings) error {
if epConfig == nil {
return nil
}
- 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 getUntilFromPruneFilters
has 5 return statements (exceeds 4 allowed). Open
Open
func getUntilFromPruneFilters(pruneFilters filters.Args) (time.Time, error) {
until := time.Time{}
if !pruneFilters.Contains("until") {
return until, nil
}
Method Daemon.releaseNetwork
has 5 return statements (exceeds 4 allowed). Open
Open
func (daemon *Daemon) releaseNetwork(container *container.Container) {
start := time.Now()
// If live-restore is enabled, the daemon cleans up dead containers when it starts up. In that case, the
// netController hasn't been initialized yet and so we can't proceed.
// TODO(aker): If we hit this case, the endpoint state won't be cleaned up (ie. no call to cleanOperationalData).
Method Daemon.containerPause
has 5 return statements (exceeds 4 allowed). Open
Open
func (daemon *Daemon) containerPause(container *container.Container) error {
container.Lock()
defer container.Unlock()
// We cannot Pause the container which is not running
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
}
Method Daemon.killWithSignal
has 5 return statements (exceeds 4 allowed). Open
Open
func (daemon *Daemon) killWithSignal(container *containerpkg.Container, stopSignal syscall.Signal) error {
log.G(context.TODO()).Debugf("Sending kill signal %d to container %s", stopSignal, container.ID)
container.Lock()
defer container.Unlock()
Method Daemon.updateNetworkSettings
has 5 return statements (exceeds 4 allowed). Open
Open
func (daemon *Daemon) updateNetworkSettings(container *container.Container, n *libnetwork.Network, endpointConfig *networktypes.EndpointSettings) error {
if container.NetworkSettings == nil {
container.NetworkSettings = &network.Settings{}
}
if container.NetworkSettings.Networks == nil {
Method Daemon.registerName
has 5 return statements (exceeds 4 allowed). Open
Open
func (daemon *Daemon) registerName(container *container.Container) error {
if daemon.Exists(container.ID) {
return fmt.Errorf("Container is already loaded")
}
if err := validateID(container.ID); err != nil {
Method Daemon.updateNetwork
has 5 return statements (exceeds 4 allowed). Open
Open
func (daemon *Daemon) updateNetwork(cfg *config.Config, container *container.Container) error {
var (
start = time.Now()
ctrl = daemon.netController
sid = container.NetworkSettings.SandboxID
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 ImageService.GetLayerFolders
has 5 return statements (exceeds 4 allowed). Open
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?