dotcloud/docker

View on GitHub
plugin/backend_linux.go

Summary

Maintainability
F
3 days
Test Coverage

File backend_linux.go has 676 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package plugin // import "github.com/docker/docker/plugin"

import (
    "archive/tar"
    "bytes"
Severity: Minor
Found in plugin/backend_linux.go - About 6 hrs to fix

    Function splitConfigRootFSFromTar has a Cognitive Complexity of 40 (exceeds 20 allowed). Consider refactoring.
    Open

    func splitConfigRootFSFromTar(in io.ReadCloser, config *[]byte) io.ReadCloser {
        pr, pw := io.Pipe()
        go func() {
            tarReader := tar.NewReader(in)
            tarWriter := tar.NewWriter(pw)
    Severity: Minor
    Found in plugin/backend_linux.go - About 3 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 Manager.CreateFromContext has 90 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (pm *Manager) CreateFromContext(ctx context.Context, tarCtx io.ReadCloser, options *types.PluginCreateOptions) (err error) {
        pm.muGC.RLock()
        defer pm.muGC.RUnlock()
    
        ref, err := reference.ParseNormalizedNamed(options.RepoName)
    Severity: Major
    Found in plugin/backend_linux.go - About 2 hrs to fix

      Method Manager.Push has 81 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (pm *Manager) Push(ctx context.Context, name string, metaHeader http.Header, authConfig *registry.AuthConfig, outStream io.Writer) error {
          p, err := pm.config.Store.GetV2Plugin(name)
          if err != nil {
              return err
          }
      Severity: Major
      Found in plugin/backend_linux.go - About 2 hrs to fix

        Method Manager.Push has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
        Open

        func (pm *Manager) Push(ctx context.Context, name string, metaHeader http.Header, authConfig *registry.AuthConfig, outStream io.Writer) error {
            p, err := pm.config.Store.GetV2Plugin(name)
            if err != nil {
                return err
            }
        Severity: Minor
        Found in plugin/backend_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 Manager.CreateFromContext has 19 return statements (exceeds 4 allowed).
        Open

        func (pm *Manager) CreateFromContext(ctx context.Context, tarCtx io.ReadCloser, options *types.PluginCreateOptions) (err error) {
            pm.muGC.RLock()
            defer pm.muGC.RUnlock()
        
            ref, err := reference.ParseNormalizedNamed(options.RepoName)
        Severity: Major
        Found in plugin/backend_linux.go - About 1 hr to fix

          Function computePrivileges has 55 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func computePrivileges(c types.PluginConfig) types.PluginPrivileges {
              var privileges types.PluginPrivileges
              if c.Network.Type != "null" && c.Network.Type != "bridge" && c.Network.Type != "" {
                  privileges = append(privileges, types.PluginPrivilege{
                      Name:        "network",
          Severity: Minor
          Found in plugin/backend_linux.go - About 1 hr to fix

            Function splitConfigRootFSFromTar has 54 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func splitConfigRootFSFromTar(in io.ReadCloser, config *[]byte) io.ReadCloser {
                pr, pw := io.Pipe()
                go func() {
                    tarReader := tar.NewReader(in)
                    tarWriter := tar.NewWriter(pw)
            Severity: Minor
            Found in plugin/backend_linux.go - About 1 hr to fix

              Method Manager.Push has 11 return statements (exceeds 4 allowed).
              Open

              func (pm *Manager) Push(ctx context.Context, name string, metaHeader http.Header, authConfig *registry.AuthConfig, outStream io.Writer) error {
                  p, err := pm.config.Store.GetV2Plugin(name)
                  if err != nil {
                      return err
                  }
              Severity: Major
              Found in plugin/backend_linux.go - About 1 hr to fix

                Method Manager.Pull has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                func (pm *Manager) Pull(ctx context.Context, ref reference.Named, name string, metaHeader http.Header, authConfig *registry.AuthConfig, privileges types.PluginPrivileges, outStream io.Writer, opts ...CreateOpt) (err error) {
                Severity: Major
                Found in plugin/backend_linux.go - About 1 hr to fix

                  Method Manager.List has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (pm *Manager) List(pluginFilters filters.Args) ([]types.Plugin, error) {
                      if err := pluginFilters.Validate(acceptedPluginFilterTags); err != nil {
                          return nil, err
                      }
                  
                  
                  Severity: Minor
                  Found in plugin/backend_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

                  Method Manager.Privileges has 9 return statements (exceeds 4 allowed).
                  Open

                  func (pm *Manager) Privileges(ctx context.Context, ref reference.Named, metaHeader http.Header, authConfig *registry.AuthConfig) (types.PluginPrivileges, error) {
                      var (
                          config     types.PluginConfig
                          configSeen bool
                      )
                  Severity: Major
                  Found in plugin/backend_linux.go - About 55 mins to fix

                    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) {
                    Severity: Major
                    Found in plugin/backend_linux.go - About 50 mins to fix

                      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
                          }
                      Severity: Major
                      Found in plugin/backend_linux.go - About 50 mins to fix

                        Method Manager.Pull has 7 return statements (exceeds 4 allowed).
                        Open

                        func (pm *Manager) Pull(ctx context.Context, ref reference.Named, name string, metaHeader http.Header, authConfig *registry.AuthConfig, privileges types.PluginPrivileges, outStream io.Writer, opts ...CreateOpt) (err error) {
                            pm.muGC.RLock()
                            defer pm.muGC.RUnlock()
                        
                            // revalidate because Pull is public
                        Severity: Major
                        Found in plugin/backend_linux.go - About 45 mins to fix

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

                          func splitConfigRootFSFromTar(in io.ReadCloser, config *[]byte) io.ReadCloser {
                              pr, pw := io.Pipe()
                              go func() {
                                  tarReader := tar.NewReader(in)
                                  tarWriter := tar.NewWriter(pw)
                          Severity: Major
                          Found in plugin/backend_linux.go - About 45 mins to fix

                            Method Manager.Remove has 6 return statements (exceeds 4 allowed).
                            Open

                            func (pm *Manager) Remove(name string, config *backend.PluginRmConfig) error {
                                p, err := pm.config.Store.GetV2Plugin(name)
                                pm.mu.RLock()
                                c := pm.cMap[p]
                                pm.mu.RUnlock()
                            Severity: Major
                            Found in plugin/backend_linux.go - About 40 mins to fix

                              Method Manager.Push has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              func (pm *Manager) Push(ctx context.Context, name string, metaHeader http.Header, authConfig *registry.AuthConfig, outStream io.Writer) error {
                              Severity: Minor
                              Found in plugin/backend_linux.go - About 35 mins to fix

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

                                func atomicRemoveAll(dir string) error {
                                    renamed := dir + "-removing"
                                
                                    err := os.Rename(dir, renamed)
                                    switch {
                                Severity: Major
                                Found in plugin/backend_linux.go - About 35 mins to fix

                                  There are no issues that match your filters.

                                  Category
                                  Status