docker/docker

View on GitHub

Showing 1,412 of 1,855 total issues

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

func (daemon *Daemon) findAndAttachNetwork(container *container.Container, idOrName string, epConfig *networktypes.EndpointSettings) (*libnetwork.Network, *networktypes.NetworkingConfig, error) {
    id := getNetworkID(idOrName, epConfig)

    n, err := daemon.FindNetwork(id)
    if err != nil {
Severity: Minor
Found in daemon/container_operations.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 client.createWindows has 147 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (c *client) createWindows(id string, spec *specs.Spec, runtimeOptions interface{}) (*container, error) {
    logger := c.logger.WithField("container", id)
    configuration := &hcsshim.ContainerConfig{
        SystemType:              "Container",
        Name:                    id,
Severity: Major
Found in libcontainerd/local/local_windows.go - About 4 hrs to fix

    Method Daemon.ContainerExecStart has 146 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (daemon *Daemon) ContainerExecStart(ctx context.Context, name string, options containertypes.ExecStartOptions) (err error) {
        var (
            cStdin           io.ReadCloser
            cStdout, cStderr io.Writer
        )
    Severity: Major
    Found in daemon/exec.go - About 4 hrs to fix

      Endpoint has 37 methods (exceeds 20 allowed). Consider refactoring.
      Open

      type Endpoint struct {
          name         string
          id           string
          network      *Network
          iface        *EndpointInterface
      Severity: Minor
      Found in libnetwork/endpoint.go - About 4 hrs to fix

        Method Controller.reservePools has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
        Open

        func (c *Controller) reservePools() {
            networks, err := c.getNetworks()
            if err != nil {
                log.G(context.TODO()).Warnf("Could not retrieve networks from local store during ipam allocation for existing networks: %v", err)
                return
        Severity: Minor
        Found in libnetwork/controller.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 WithNamespaces has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
        Open

        func WithNamespaces(daemon *Daemon, c *container.Container) coci.SpecOpts {
            return func(ctx context.Context, _ coci.Client, _ *containers.Container, s *coci.Spec) error {
                userNS := false
                // user
                if c.HostConfig.UsernsMode.IsPrivate() {
        Severity: Minor
        Found in daemon/oci_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 ImageService.pruneUnused has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
        Open

        func (i *ImageService) pruneUnused(ctx context.Context, filterFunc imageFilterFunc, danglingOnly bool) (*types.ImagesPruneReport, error) {
            report := types.ImagesPruneReport{}
        
            allImages, err := i.images.List(ctx)
            if err != nil {
        Severity: Minor
        Found in daemon/containerd/image_prune.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.containerStart has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
        Open

        func (daemon *Daemon) containerStart(ctx context.Context, daemonCfg *configStore, container *container.Container, checkpoint string, checkpointDir string, resetRestartManager bool) (retErr error) {
            start := time.Now()
            container.Lock()
            defer container.Unlock()
        
        
        Severity: Minor
        Found in daemon/start.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 walker.walk has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
        Open

        func (w *walker) walk(path string, i1, i2 os.FileInfo) (err error) {
            // Register these nodes with the return trees, unless we're still at the
            // (already-created) roots:
            if path != "/" {
                if err := walkchunk(path, i1, w.dir1, w.root1); err != nil {
        Severity: Minor
        Found in pkg/archive/changes_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 PeerRecord.Unmarshal has 143 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

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

          Method PluginPrivilege.Unmarshal has 143 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (m *PluginPrivilege) Unmarshal(dAtA []byte) error {
              l := len(dAtA)
              iNdEx := 0
              for iNdEx < l {
                  preIndex := iNdEx
          Severity: Major
          Found in api/types/swarm/runtime/plugin.pb.go - About 4 hrs to fix

            Function DefaultLinuxSpec has 142 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func DefaultLinuxSpec() specs.Spec {
                return specs.Spec{
                    Version: specs.Version,
                    Process: &specs.Process{
                        Capabilities: &specs.LinuxCapabilities{
            Severity: Major
            Found in oci/defaults.go - About 4 hrs to fix

              Method Daemon.buildSandboxOptions has 141 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (daemon *Daemon) buildSandboxOptions(cfg *config.Config, container *container.Container) ([]libnetwork.SandboxOption, error) {
                  var sboxOptions []libnetwork.SandboxOption
                  sboxOptions = append(sboxOptions, libnetwork.OptionHostname(container.Config.Hostname), libnetwork.OptionDomainname(container.Config.Domainname))
              
                  if container.HostConfig.NetworkMode.IsHost() {
              Severity: Major
              Found in daemon/container_operations.go - About 4 hrs to fix

                Method Cluster.CreateService has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring.
                Open

                func (c *Cluster) CreateService(s swarm.ServiceSpec, encodedAuth string, queryRegistry bool) (*swarm.ServiceCreateResponse, error) {
                    var resp *swarm.ServiceCreateResponse
                    err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
                        err := c.populateNetworkID(ctx, state.controlClient, &s)
                        if err != nil {
                Severity: Minor
                Found in daemon/cluster/services.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 138 lines of code (exceeds 50 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: Major
                Found in libnetwork/drivers/bridge/bridge_linux.go - About 4 hrs to fix

                  Function compare has 137 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func compare(a, b *container.Config) bool {
                      if a == nil || b == nil {
                          return false
                      }
                  
                  
                  Severity: Major
                  Found in image/cache/compare.go - About 4 hrs to fix

                    Function includeContainerInList has 137 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func includeContainerInList(container *container.Snapshot, filter *listContext) iterationAction {
                        // Do not include container if it's in the list before the filter container.
                        // Set the filter container to nil to include the rest of containers after this one.
                        if filter.beforeFilter != nil {
                            if container.ID == filter.beforeFilter.ID {
                    Severity: Major
                    Found in daemon/list.go - About 4 hrs to fix

                      Method PortConfig.Unmarshal has 136 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

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

                        Function withFetchProgress has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func withFetchProgress(cs content.Store, out progress.Output, ref reference.Named) images.HandlerFunc {
                            return func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
                                switch desc.MediaType {
                                case ocispec.MediaTypeImageManifest, images.MediaTypeDockerSchema2Manifest:
                                    tn := reference.TagNameOnly(ref)
                        Severity: Minor
                        Found in plugin/fetch_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 Daemon.setupMounts has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func (daemon *Daemon) setupMounts(ctx context.Context, c *container.Container) ([]container.Mount, func(context.Context) error, error) {
                            var mounts []container.Mount
                            // TODO: tmpfs mounts should be part of Mountpoints
                            tmpfsMounts := make(map[string]bool)
                            tmpfsMountInfo, err := c.TmpfsMounts()
                        Severity: Minor
                        Found in daemon/volumes_unix.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