daemon/info_unix.go
Method Daemon.fillPlatformInfo
has a Cognitive Complexity of 63 (exceeds 20 allowed). Consider refactoring. Open
Open
func (daemon *Daemon) fillPlatformInfo(ctx context.Context, v *system.Info, sysInfo *sysinfo.SysInfo, cfg *configStore) error {
v.CgroupDriver = cgroupDriver(&cfg.Config)
v.CgroupVersion = "1"
if sysInfo.CgroupUnified {
v.CgroupVersion = "2"
- 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.fillPlatformInfo
has 124 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (daemon *Daemon) fillPlatformInfo(ctx context.Context, v *system.Info, sysInfo *sysinfo.SysInfo, cfg *configStore) error {
v.CgroupDriver = cgroupDriver(&cfg.Config)
v.CgroupVersion = "1"
if sysInfo.CgroupUnified {
v.CgroupVersion = "2"
Method Daemon.fillRootlessVersion
has 75 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (daemon *Daemon) fillRootlessVersion(ctx context.Context, v *types.Version) error {
if !rootless.RunningWithRootlessKit() {
return nil
}
rlc, err := getRootlessKitClient()
Method Daemon.fillRootlessVersion
has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring. Open
Open
func (daemon *Daemon) fillRootlessVersion(ctx context.Context, v *types.Version) error {
if !rootless.RunningWithRootlessKit() {
return nil
}
rlc, err := getRootlessKitClient()
- 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.fillRootlessVersion
has 13 return statements (exceeds 4 allowed). Open
Open
func (daemon *Daemon) fillRootlessVersion(ctx context.Context, v *types.Version) error {
if !rootless.RunningWithRootlessKit() {
return nil
}
rlc, err := getRootlessKitClient()
Method Daemon.populateInitCommit
has 5 return statements (exceeds 4 allowed). Open
Open
func (daemon *Daemon) populateInitCommit(ctx context.Context, v *system.Info, cfg *configStore) error {
v.InitBinary = cfg.GetInitPath()
initBinary, err := cfg.LookupInitPath()
if err != nil {
log.G(ctx).WithError(err).Warnf("Failed to find docker-init")
Function populateInitVersion
has 5 return statements (exceeds 4 allowed). Open
Open
func populateInitVersion(ctx context.Context, cfg *configStore, v *types.Version) error {
initBinary, err := cfg.LookupInitPath()
if err != nil {
log.G(ctx).WithError(err).Warn("Failed to find docker-init")
return 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
}