docker/docker

View on GitHub

Showing 1,412 of 1,855 total issues

Method Info.ExtraAttributes has a Cognitive Complexity of 51 (exceeds 20 allowed). Consider refactoring.
Open

func (info *Info) ExtraAttributes(keyMod func(string) string) (map[string]string, error) {
    extra := make(map[string]string)
    labels, ok := info.Config["labels"]
    if ok && len(labels) > 0 {
        for _, l := range strings.Split(labels, ",") {
Severity: Minor
Found in daemon/logger/loginfo.go - About 5 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 tarSum.Read has a Cognitive Complexity of 51 (exceeds 20 allowed). Consider refactoring.
Open

func (ts *tarSum) Read(buf []byte) (int, error) {
    if ts.finished {
        return ts.bufWriter.Read(buf)
    }
    if len(ts.bufData) < len(buf) {
Severity: Minor
Found in pkg/tarsum/tarsum.go - About 5 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 EndpointRecord.Unmarshal has 61 return statements (exceeds 4 allowed).
Open

func (m *EndpointRecord) Unmarshal(dAtA []byte) error {
    l := len(dAtA)
    iNdEx := 0
    for iNdEx < l {
        preIndex := iNdEx
Severity: Major
Found in libnetwork/agent.pb.go - About 5 hrs to fix

    Method Config.CopyStreams has a Cognitive Complexity of 50 (exceeds 20 allowed). Consider refactoring.
    Open

    func (c *Config) CopyStreams(ctx context.Context, cfg *AttachConfig) <-chan error {
        var group errgroup.Group
    
        // Connect stdin of container to the attach stdin stream.
        if cfg.Stdin != nil {
    Severity: Minor
    Found in container/stream/attach.go - About 5 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 linuxParser.validateMountConfigImpl has a Cognitive Complexity of 50 (exceeds 20 allowed). Consider refactoring.
    Open

    func (p *linuxParser) validateMountConfigImpl(mnt *mount.Mount, validateBindSourceExists bool) error {
        if len(mnt.Target) == 0 {
            return &errMountConfig{mnt, errMissingField("Target")}
        }
    
    
    Severity: Minor
    Found in volume/mounts/linux_parser.go - About 5 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.ProcessEvent has a Cognitive Complexity of 50 (exceeds 20 allowed). Consider refactoring.
    Open

    func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei libcontainerdtypes.EventInfo) error {
        c, err := daemon.GetContainer(id)
        if err != nil {
            return errors.Wrapf(err, "could not find container %s", id)
        }
    Severity: Minor
    Found in daemon/monitor.go - About 5 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

    Controller has 39 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type Controller struct {
        id               string
        drvRegistry      drvregistry.Networks
        ipamRegistry     drvregistry.IPAMs
        sandboxes        map[string]*Sandbox
    Severity: Minor
    Found in libnetwork/controller.go - About 5 hrs to fix

      File layer_store.go has 630 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      package layer // import "github.com/docker/docker/layer"
      
      import (
          "context"
          "errors"
      Severity: Minor
      Found in layer/layer_store.go - About 5 hrs to fix

        Method PortMapper.MapRange has a Cognitive Complexity of 49 (exceeds 20 allowed). Consider refactoring.
        Open

        func (pm *PortMapper) MapRange(container net.Addr, hostIP net.IP, hostPortStart, hostPortEnd int, useProxy bool) (host net.Addr, retErr error) {
            pm.lock.Lock()
            defer pm.lock.Unlock()
        
            var (
        Severity: Minor
        Found in libnetwork/portmapper/mapper.go - About 5 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

        Function withMounts has 152 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func withMounts(daemon *Daemon, daemonCfg *configStore, c *container.Container, ms []container.Mount) coci.SpecOpts {
            return func(ctx context.Context, _ coci.Client, _ *containers.Container, s *coci.Spec) (err error) {
                sort.Sort(mounts(ms))
        
                mounts := ms
        Severity: Major
        Found in daemon/oci_linux.go - About 5 hrs to fix

          Method NetworkEntry.Unmarshal has 150 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (m *NetworkEntry) Unmarshal(dAtA []byte) error {
              l := len(dAtA)
              iNdEx := 0
              for iNdEx < l {
                  preIndex := iNdEx
          Severity: Major
          Found in libnetwork/networkdb/networkdb.pb.go - About 5 hrs to fix

            Method NetworkEvent.Unmarshal has 149 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (m *NetworkEvent) Unmarshal(dAtA []byte) error {
                l := len(dAtA)
                iNdEx := 0
                for iNdEx < l {
                    preIndex := iNdEx
            Severity: Major
            Found in libnetwork/networkdb/networkdb.pb.go - About 4 hrs to fix

              Method containerRouter.postContainersCreate has 149 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (s *containerRouter) postContainersCreate(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
                  if err := httputils.ParseForm(r); err != nil {
                      return err
                  }
                  if err := httputils.CheckForJSON(r); err != nil {
              Severity: Major
              Found in api/server/router/container/container_routes.go - About 4 hrs to fix

                File client.go has 623 lines of code (exceeds 500 allowed). Consider refactoring.
                Open

                package remote // import "github.com/docker/docker/libcontainerd/remote"
                
                import (
                    "context"
                    "encoding/json"
                Severity: Minor
                Found in libcontainerd/remote/client.go - About 4 hrs to fix

                  Method layerDescriptor.Download has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (ld *layerDescriptor) Download(ctx context.Context, progressOutput progress.Output) (io.ReadCloser, int64, error) {
                      log.G(ctx).Debugf("pulling blob %q", ld.digest)
                  
                      var (
                          err    error
                  Severity: Minor
                  Found in distribution/pull_v2.go - About 4 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 puller.pullTag has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (p *puller) pullTag(ctx context.Context, ref reference.Named, platform *ocispec.Platform) (tagUpdated bool, err error) {
                      var (
                          tagOrDigest string // Used for logging/progress only
                          dgst        digest.Digest
                          mt          string
                  Severity: Minor
                  Found in distribution/pull_v2.go - About 4 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 driver.CreateEndpoint has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error {
                      if ifInfo == nil {
                          return errors.New("invalid interface info passed")
                      }
                  
                  
                  Severity: Minor
                  Found in libnetwork/drivers/bridge/bridge_linux.go - About 4 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 imageRouter.postImagesCreate has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (ir *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
                      if err := httputils.ParseForm(r); err != nil {
                          return err
                      }
                  
                  
                  Severity: Minor
                  Found in api/server/router/image/image_routes.go - About 4 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.ContainerLogs has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (daemon *Daemon) ContainerLogs(ctx context.Context, containerName string, config *containertypes.LogsOptions) (messages <-chan *backend.LogMessage, isTTY bool, retErr error) {
                      lg := log.G(ctx).WithFields(log.Fields{
                          "module":    "daemon",
                          "method":    "(*Daemon).ContainerLogs",
                          "container": containerName,
                  Severity: Minor
                  Found in daemon/logs.go - About 4 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

                  Function containerToGRPC has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func containerToGRPC(c *types.ContainerSpec) (*swarmapi.ContainerSpec, error) {
                      containerSpec := &swarmapi.ContainerSpec{
                          Image:          c.Image,
                          Labels:         c.Labels,
                          Command:        c.Command,
                  Severity: Minor
                  Found in daemon/cluster/convert/container.go - About 4 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

                  Severity
                  Category
                  Status
                  Source
                  Language