dotcloud/docker

View on GitHub

Showing 1,468 of 1,914 total issues

Method tarexporter.legacyLoad has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
Open

func (l *tarexporter) legacyLoad(tmpDir string, outStream io.Writer, progressOutput progress.Output) error {
    if runtime.GOOS == "windows" {
        return errors.New("Windows does not support legacy loading of images")
    }

Severity: Minor
Found in image/tarexport/load.go - About 45 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

Function newRepository has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    ctx context.Context, repoInfo *registry.RepositoryInfo, endpoint registry.APIEndpoint,
    metaHeaders http.Header, authConfig *registrytypes.AuthConfig, actions ...string,
Severity: Minor
Found in distribution/registry.go - About 45 mins to fix

    Method manifestStore.getLocal has 7 return statements (exceeds 4 allowed).
    Open

    func (m *manifestStore) getLocal(ctx context.Context, desc ocispec.Descriptor, ref reference.Named) (distribution.Manifest, error) {
        ra, err := m.local.ReaderAt(ctx, desc)
        if err != nil {
            return nil, errors.Wrap(err, "error getting content store reader")
        }
    Severity: Major
    Found in distribution/manifest.go - About 45 mins to fix

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

      func EnsureRemoveAll(dir string) error {
          notExistErr := make(map[string]bool)
      
          // track retries
          exitOnErr := make(map[string]int)
      Severity: Major
      Found in internal/containerfs/rm.go - About 45 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

          Method store.restore has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
          Open

          func (is *store) restore() error {
              // As the code below is run when restoring all images (which can be "many"),
              // constructing the "log.G(ctx).WithFields" is deliberately not "DRY", as the
              // logger is only used for error-cases, and we don't want to do allocations
              // if we don't need it. The "f" type alias is here is just for convenience,
          Severity: Minor
          Found in image/store.go - About 45 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 KernelVersion.UnmarshalJSON has 7 return statements (exceeds 4 allowed).
          Open

          func (k *KernelVersion) UnmarshalJSON(version []byte) error {
              var (
                  ver string
                  err error
              )
          Severity: Major
          Found in profiles/seccomp/seccomp.go - About 45 mins to fix

            Method Store.resolvePluginID has 7 return statements (exceeds 4 allowed).
            Open

            func (ps *Store) resolvePluginID(idOrName string) (string, error) {
                if validFullID.MatchString(idOrName) {
                    return idOrName, nil
                }
            
            
            Severity: Major
            Found in plugin/store.go - About 45 mins to fix

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

              func kubernetesSafeOpen(base, subpath string) (int, error) {
                  // syscall.Openat flags used to traverse directories not following symlinks
                  const nofollowFlags = unix.O_RDONLY | unix.O_NOFOLLOW
                  // flags for getting file descriptor without following the symlink
                  const openFDFlags = unix.O_NOFOLLOW | unix.O_PATH
              Severity: Major
              Found in internal/safepath/k8s_safeopen_linux.go - About 45 mins to fix

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

                func evaluatePath(path, subpath string) (resolvedBasePath string, resolvedSubpath string, err error) {
                    baseResolved, err := filepath.EvalSymlinks(path)
                    if err != nil {
                        if errors.Is(err, os.ErrNotExist) {
                            return "", "", &ErrNotAccessible{Path: path, Cause: err}
                Severity: Major
                Found in internal/safepath/common.go - About 45 mins to fix

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

                  func isHostNS(spec *specs.Spec, nsType specs.LinuxNamespaceType) (bool, error) {
                      if strings.Contains(string(nsType), string(os.PathSeparator)) {
                          return false, fmt.Errorf("unexpected namespace type %q", nsType)
                      }
                      if spec.Linux == nil {
                  Severity: Major
                  Found in internal/rootless/specconv/specconv_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

                      Avoid deeply nested control flow statements.
                      Open

                                  } else if len(output) != 0 {
                                      return fmt.Errorf("could not delete establish rule from %s: %s", c.Table, output)
                                  }
                      Severity: Major
                      Found in libnetwork/iptables/iptables.go - About 45 mins to fix

                        Method Controller.addEndpointNameResolution has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        func (c *Controller) addEndpointNameResolution(svcName, svcID, nID, eID, containerName string, vip net.IP, serviceAliases, taskAliases []string, ip net.IP, addService bool, method string) error {
                        Severity: Minor
                        Found in libnetwork/service_common.go - About 45 mins to fix

                          Method Controller.NewSandbox has 7 return statements (exceeds 4 allowed).
                          Open

                          func (c *Controller) NewSandbox(ctx context.Context, containerID string, options ...SandboxOption) (_ *Sandbox, retErr error) {
                              if containerID == "" {
                                  return nil, types.InvalidParameterErrorf("invalid container ID")
                              }
                          
                          
                          Severity: Major
                          Found in libnetwork/controller.go - About 45 mins to fix

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

                            func NewAllocator(lcAs, glAs []*ipamutils.NetworkToSplit) (*Allocator, error) {
                                var (
                                    a                          Allocator
                                    err                        error
                                    lcAs4, lcAs6, glAs4, glAs6 []*ipamutils.NetworkToSplit
                            Severity: Major
                            Found in libnetwork/ipams/defaultipam/allocator.go - About 45 mins to fix

                              Method Controller.handleEpTableEvent has 7 return statements (exceeds 4 allowed).
                              Open

                              func (c *Controller) handleEpTableEvent(ev events.Event) {
                                  var (
                                      nid   string
                                      eid   string
                                      value []byte
                              Severity: Major
                              Found in libnetwork/agent.go - About 45 mins to fix

                                Method PortAllocator.RequestPortsInRange has 7 return statements (exceeds 4 allowed).
                                Open

                                func (p *PortAllocator) RequestPortsInRange(ips []net.IP, proto string, portStart, portEnd int) (int, error) {
                                    if proto != "tcp" && proto != "udp" && proto != "sctp" {
                                        return 0, ErrUnknownProtocol
                                    }
                                
                                
                                Severity: Major
                                Found in libnetwork/portallocator/portallocator.go - About 45 mins to fix

                                  Method Controller.addServiceBinding has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                  func (c *Controller) addServiceBinding(svcName, svcID, nID, eID, containerName string, vip net.IP, ingressPorts []*PortConfig, serviceAliases, taskAliases []string, ip net.IP, method string) error {
                                  Severity: Minor
                                  Found in libnetwork/service_common.go - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                } else if len(output) != 0 {
                                                    return fmt.Errorf("could not delete linking rule from %s/%s: %s", c.Table, c.Name, output)
                                                }
                                    Severity: Major
                                    Found in libnetwork/iptables/iptables.go - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language