dotcloud/docker

View on GitHub
daemon/daemon_linux.go

Summary

Maintainability
B
5 hrs
Test Coverage

Function kernelSupportsRecursivelyReadOnly has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
Open

func kernelSupportsRecursivelyReadOnly() error {
    fn := func() error {
        tmpMnt, err := os.MkdirTemp("", "moby-detect-rro")
        if err != nil {
            return fmt.Errorf("failed to create a temp directory: %w", err)
Severity: Minor
Found in daemon/daemon_linux.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.cleanupMountsFromReaderByID has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
Open

func (daemon *Daemon) cleanupMountsFromReaderByID(reader io.Reader, id string, unmount func(target string) error) error {
    if daemon.root == "" {
        return nil
    }
    var errs []string
Severity: Minor
Found in daemon/daemon_linux.go - About 55 mins 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

Avoid deeply nested control flow statements.
Open

                        if err := unmount(mnt); err != nil {
                            log.G(context.TODO()).Error(err)
                            errs = append(errs, err.Error())
                        }
Severity: Major
Found in daemon/daemon_linux.go - About 45 mins to fix

    Method Daemon.cleanupMounts has 7 return statements (exceeds 4 allowed).
    Open

    func (daemon *Daemon) cleanupMounts(cfg *config.Config) error {
        if err := daemon.cleanupMountsByID(""); err != nil {
            return err
        }
    
    
    Severity: Major
    Found in daemon/daemon_linux.go - About 45 mins to fix

      Function ifaceAddrs has 7 return statements (exceeds 4 allowed).
      Open

      func ifaceAddrs(linkName string) (v4, v6 []*net.IPNet, err error) {
          nl := ns.NlHandle()
          link, err := nl.LinkByName(linkName)
          if err != nil {
              if !errors.As(err, new(netlink.LinkNotFoundError)) {
      Severity: Major
      Found in daemon/daemon_linux.go - About 45 mins to fix

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

        func kernelSupportsRecursivelyReadOnly() error {
            fn := func() error {
                tmpMnt, err := os.MkdirTemp("", "moby-detect-rro")
                if err != nil {
                    return fmt.Errorf("failed to create a temp directory: %w", err)
        Severity: Major
        Found in daemon/daemon_linux.go - About 35 mins to fix

          There are no issues that match your filters.

          Category
          Status