dotcloud/docker

View on GitHub

Showing 1,468 of 1,914 total issues

Function parseUintList has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
Open

func parseUintList(val string, maximum int) (map[int]bool, error) {
    if val == "" {
        return map[int]bool{}, nil
    }

Severity: Minor
Found in pkg/parsers/parsers.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 cnmNetworkAllocator.AllocateService has 64 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (na *cnmNetworkAllocator) AllocateService(s *api.Service) (err error) {
    defer func() {
        if err != nil {
            na.DeallocateService(s)
        }
Severity: Minor
Found in libnetwork/cnmallocator/networkallocator.go - About 1 hr to fix

    Function dispatch has 64 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func dispatch(ctx context.Context, d dispatchRequest, cmd instructions.Command) (err error) {
        if c, ok := cmd.(instructions.PlatformSpecific); ok {
            err := c.CheckPlatform(d.state.operatingSystem)
            if err != nil {
                return errdefs.InvalidParameter(err)
    Severity: Minor
    Found in builder/dockerfile/evaluator.go - About 1 hr to fix

      Method cacheAdaptor.Get has 64 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (c cacheAdaptor) Get(id image.ID) (*image.Image, error) {
          ctx := context.TODO()
          ref := id.String()
      
          outImg, err := c.is.GetImage(ctx, id.String(), backend.GetImageOpts{})
      Severity: Minor
      Found in daemon/containerd/cache.go - About 1 hr to fix

        Method ImageService.resolveImage has 64 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (i *ImageService) resolveImage(ctx context.Context, refOrID string) (containerdimages.Image, error) {
            parsed, err := reference.ParseAnyReference(refOrID)
            if err != nil {
                return containerdimages.Image{}, errdefs.InvalidParameter(err)
            }
        Severity: Minor
        Found in daemon/containerd/image.go - About 1 hr to fix

          Method splunkLogger.tryPostMessages has 64 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (l *splunkLogger) tryPostMessages(ctx context.Context, messages []*splunkMessage) error {
              if len(messages) == 0 {
                  return nil
              }
              var buffer bytes.Buffer
          Severity: Minor
          Found in daemon/logger/splunk/splunk.go - About 1 hr to fix

            Method Plugin.Set has 63 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (p *Plugin) Set(args []string) error {
                p.mu.Lock()
                defer p.mu.Unlock()
            
                if p.PluginObj.Enabled {
            Severity: Minor
            Found in plugin/v2/plugin.go - About 1 hr to fix

              Method RestartManager.ShouldRestart has 63 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (rm *RestartManager) ShouldRestart(exitCode uint32, hasBeenManuallyStopped bool, executionDuration time.Duration) (bool, chan error, error) {
                  if rm.policy.IsNone() {
                      return false, nil, nil
                  }
                  rm.Lock()
              Severity: Minor
              Found in restartmanager/restartmanager.go - About 1 hr to fix

                Method Daemon.ContainerAttach has 63 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (daemon *Daemon) ContainerAttach(prefixOrName string, req *backend.ContainerAttachConfig) error {
                    keys := []byte{}
                    var err error
                    if req.DetachKeys != "" {
                        keys, err = term.ToBytes(req.DetachKeys)
                Severity: Minor
                Found in daemon/attach.go - About 1 hr to fix

                  Method CompoundMessage.Unmarshal has 16 return statements (exceeds 4 allowed).
                  Open

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

                    Method driver.CreateEndpoint has 16 return statements (exceeds 4 allowed).
                    Open

                    func (d *driver) CreateEndpoint(ctx context.Context, nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error {
                        var err error
                        if err = validateID(nid, eid); err != nil {
                            return err
                        }
                    Severity: Major
                    Found in libnetwork/drivers/windows/overlay/ov_endpoint_windows.go - About 1 hr to fix

                      Method containerRouter.postContainersCreate has 16 return statements (exceeds 4 allowed).
                      Open

                      func (c *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 1 hr to fix

                        Method ImageService.ImageDelete has 16 return statements (exceeds 4 allowed).
                        Open

                        func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force, prune bool) (response []imagetypes.DeleteResponse, retErr error) {
                            start := time.Now()
                            defer func() {
                                if retErr == nil {
                                    dimages.ImageActions.WithValues("delete").UpdateSince(start)
                        Severity: Major
                        Found in daemon/containerd/image_delete.go - About 1 hr to fix

                          Method Cluster.Init has 16 return statements (exceeds 4 allowed).
                          Open

                          func (c *Cluster) Init(req types.InitRequest) (string, error) {
                              c.controlMutex.Lock()
                              defer c.controlMutex.Unlock()
                              if c.nr != nil {
                                  if req.ForceNewCluster {
                          Severity: Major
                          Found in daemon/cluster/swarm.go - About 1 hr to fix

                            Method Daemon.connectToNetwork has 16 return statements (exceeds 4 allowed).
                            Open

                            func (daemon *Daemon) connectToNetwork(ctx context.Context, cfg *config.Config, ctr *container.Container, idOrName string, endpointConfig *network.EndpointSettings, updateSettings bool) (retErr error) {
                                containerName := strings.TrimPrefix(ctr.Name, "/")
                                ctx, span := otel.Tracer("").Start(ctx, "daemon.connectToNetwork", trace.WithAttributes(
                                    attribute.String("container.ID", ctr.ID),
                                    attribute.String("container.name", containerName),
                            Severity: Major
                            Found in daemon/container_operations.go - About 1 hr to fix

                              Function newRepository has 62 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func newRepository(
                                  ctx context.Context, repoInfo *registry.RepositoryInfo, endpoint registry.APIEndpoint,
                                  metaHeaders http.Header, authConfig *registrytypes.AuthConfig, actions ...string,
                              ) (distribution.Repository, error) {
                                  repoName := repoInfo.Name.Name()
                              Severity: Minor
                              Found in distribution/registry.go - About 1 hr to fix

                                Method Network.Services has 62 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func (n *Network) Services() map[string]ServiceInfo {
                                    agent, ok := n.clusterAgent()
                                    if !ok {
                                        return nil
                                    }
                                Severity: Minor
                                Found in libnetwork/agent.go - About 1 hr to fix

                                  Method Controller.rmServiceBinding has 62 lines of code (exceeds 50 allowed). Consider refactoring.
                                  Open

                                  func (c *Controller) rmServiceBinding(svcName, svcID, nID, eID, containerName string, vip net.IP, ingressPorts []*PortConfig, serviceAliases []string, taskAliases []string, ip net.IP, method string, deleteSvcRecords bool, fullRemove bool) error {
                                      var rmService bool
                                  
                                      skey := serviceKey{
                                          id:    svcID,
                                  Severity: Minor
                                  Found in libnetwork/service_common.go - About 1 hr to fix

                                    Method driver.link has 62 lines of code (exceeds 50 allowed). Consider refactoring.
                                    Open

                                    func (d *driver) link(network *bridgeNetwork, endpoint *bridgeEndpoint, enable bool) (retErr error) {
                                        cc := endpoint.containerConfig
                                        ec := endpoint.extConnConfig
                                        if cc == nil || ec == nil || (len(cc.ParentEndpoints) == 0 && len(cc.ChildEndpoints) == 0) {
                                            // nothing to do
                                    Severity: Minor
                                    Found in libnetwork/drivers/bridge/bridge_linux.go - About 1 hr to fix

                                      Function monitor has 62 lines of code (exceeds 50 allowed). Consider refactoring.
                                      Open

                                      func monitor(d *Daemon, c *container.Container, stop chan struct{}, probe probe) {
                                          probeInterval := timeoutWithDefault(c.Config.Healthcheck.Interval, defaultProbeInterval)
                                          startInterval := timeoutWithDefault(c.Config.Healthcheck.StartInterval, defaultStartInterval)
                                          startPeriod := timeoutWithDefault(c.Config.Healthcheck.StartPeriod, defaultStartPeriod)
                                      
                                      
                                      Severity: Minor
                                      Found in daemon/health.go - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language