docker/docker

View on GitHub
daemon/info_unix.go

Summary

Maintainability
D
2 days
Test Coverage

Method Daemon.fillPlatformInfo has a Cognitive Complexity of 63 (exceeds 20 allowed). Consider refactoring.
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"
Severity: Minor
Found in daemon/info_unix.go - About 7 hrs to fix

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

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"
Severity: Major
Found in daemon/info_unix.go - About 3 hrs to fix

    Method Daemon.fillRootlessVersion has 75 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (daemon *Daemon) fillRootlessVersion(ctx context.Context, v *types.Version) error {
        if !rootless.RunningWithRootlessKit() {
            return nil
        }
        rlc, err := getRootlessKitClient()
    Severity: Minor
    Found in daemon/info_unix.go - About 2 hrs to fix

      Method Daemon.fillRootlessVersion has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
      Open

      func (daemon *Daemon) fillRootlessVersion(ctx context.Context, v *types.Version) error {
          if !rootless.RunningWithRootlessKit() {
              return nil
          }
          rlc, err := getRootlessKitClient()
      Severity: Minor
      Found in daemon/info_unix.go - About 1 hr to fix

      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

      func (daemon *Daemon) fillRootlessVersion(ctx context.Context, v *types.Version) error {
          if !rootless.RunningWithRootlessKit() {
              return nil
          }
          rlc, err := getRootlessKitClient()
      Severity: Major
      Found in daemon/info_unix.go - About 1 hr to fix

        Function populateInitVersion has 5 return statements (exceeds 4 allowed).
        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
        Severity: Major
        Found in daemon/info_unix.go - About 35 mins to fix

          Function parseDefaultRuntimeVersion has 5 return statements (exceeds 4 allowed).
          Open

          func parseDefaultRuntimeVersion(rts *runtimes) (runtime, version, commit string, err error) {
              shim, opts, err := rts.Get(rts.Default)
              if err != nil {
                  return "", "", "", err
              }
          Severity: Major
          Found in daemon/info_unix.go - About 35 mins to fix

            Method Daemon.populateInitCommit has 5 return statements (exceeds 4 allowed).
            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")
            Severity: Major
            Found in daemon/info_unix.go - About 35 mins to fix

              There are no issues that match your filters.

              Category
              Status