dotcloud/docker

View on GitHub

Showing 1,468 of 1,914 total issues

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 tarexporter.legacyLoadImage has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
Open

func (l *tarexporter) legacyLoadImage(oldID, sourceDir string, loadedMap map[string]image.ID, progressOutput progress.Output) error {
    if _, loaded := loadedMap[oldID]; loaded {
        return nil
    }
    configPath, err := safePath(sourceDir, filepath.Join(oldID, legacyConfigFileName))
Severity: Minor
Found in image/tarexport/load.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

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

    func (r *Resolver) serveDNS(w dns.ResponseWriter, query *dns.Msg) {
        var (
            resp *dns.Msg
            err  error
        )
    Severity: Minor
    Found in libnetwork/resolver.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 driver.createNetwork has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
    Open

    func (d *driver) createNetwork(config *configuration) (bool, error) {
        foundExisting := false
        networkList := d.getNetworks()
        for _, nw := range networkList {
            if config.Parent == nw.config.Parent {
    Severity: Minor
    Found in libnetwork/drivers/macvlan/macvlan_network.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 systemRouter.getDiskUsage has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
    Open

    func (s *systemRouter) getDiskUsage(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/system/system_routes.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 systemRouter.getEvents has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
    Open

    func (s *systemRouter) getEvents(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/system/system_routes.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 systemRouter.getInfo has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
    Open

    func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
        version := httputils.VersionFromContext(ctx)
        info, _, _ := s.collectSystemInfo.Do(ctx, version, func(ctx context.Context) (*system.Info, error) {
            info, err := s.backend.SystemInfo(ctx)
            if err != nil {
    Severity: Minor
    Found in api/server/router/system/system_routes.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 networkRouter.findUniqueNetwork has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
    Open

    func (n *networkRouter) findUniqueNetwork(term string) (network.Inspect, error) {
        listByFullName := map[string]network.Inspect{}
        listByPartialID := map[string]network.Inspect{}
    
        filter := filters.NewArgs(filters.Arg("idOrName", term))
    Severity: Minor
    Found in api/server/router/network/network_routes.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

    Function GetTimestamp has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
    Open

    func GetTimestamp(value string, reference time.Time) (string, error) {
        if d, err := time.ParseDuration(value); value != "0" && err == nil {
            return strconv.FormatInt(reference.Add(-d).Unix(), 10), nil
        }
    
    
    Severity: Minor
    Found in api/types/time/timestamp.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

    Function withCgroups has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
    Open

    func withCgroups(daemon *Daemon, daemonCfg *dconfig.Config, c *container.Container) coci.SpecOpts {
        return func(ctx context.Context, _ coci.Client, _ *containers.Container, s *coci.Spec) error {
            var cgroupsPath string
            scopePrefix := "docker"
            parent := "/docker"
    Severity: Minor
    Found in daemon/oci_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 ImageService.unleaseSnapshotsFromDeletedConfigs has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
    Open

    func (i *ImageService) unleaseSnapshotsFromDeletedConfigs(ctx context.Context, possiblyDeletedConfigs map[digest.Digest]struct{}) error {
        all, err := i.images.List(ctx)
        if err != nil {
            return errors.Wrap(err, "failed to list images during snapshot lease removal")
        }
    Severity: Minor
    Found in daemon/containerd/image_prune.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 executor.Configure has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
    Open

    func (e *executor) Configure(ctx context.Context, node *api.Node) error {
        var ingressNA *api.NetworkAttachment
        attachments := make(map[string]string)
    
        for _, na := range node.Attachments {
    Severity: Minor
    Found in daemon/cluster/executor/container/executor.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 Daemon.containerStart has 19 return statements (exceeds 4 allowed).
    Open

    func (daemon *Daemon) containerStart(ctx context.Context, daemonCfg *configStore, container *container.Container, checkpoint string, checkpointDir string, resetRestartManager bool) (retErr error) {
        ctx, span := otel.Tracer("").Start(ctx, "daemon.containerStart", trace.WithAttributes(
            attribute.String("container.ID", container.ID),
            attribute.String("container.Name", container.Name)))
        defer span.End()
    Severity: Major
    Found in daemon/start.go - About 1 hr to fix

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

      func (daemon *Daemon) cleanupContainer(container *container.Container, config backend.ContainerRmConfig) error {
          if container.IsRunning() {
              if !config.ForceRemove {
                  if state := container.StateString(); state == "paused" {
                      return errdefs.Conflict(fmt.Errorf("cannot remove container %q: container is %s and must be unpaused first", container.Name, state))
      Severity: Minor
      Found in daemon/delete.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

      Function containerSpecFromGRPC has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
      Open

      func containerSpecFromGRPC(c *swarmapi.ContainerSpec) *types.ContainerSpec {
          if c == nil {
              return nil
          }
          containerSpec := &types.ContainerSpec{
      Severity: Minor
      Found in daemon/cluster/convert/container.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

      Function getConflictFreeConfiguration has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
      Open

      func getConflictFreeConfiguration(configFile string, flags *pflag.FlagSet) (*Config, error) {
          b, err := os.ReadFile(configFile)
          if err != nil {
              return nil, err
          }
      Severity: Minor
      Found in daemon/config/config.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

      Function findConfigurationConflicts has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
      Open

      func findConfigurationConflicts(config map[string]interface{}, flags *pflag.FlagSet) error {
          // 1. Search keys from the file that we don't recognize as flags.
          unknownKeys := make(map[string]interface{})
          for key, value := range config {
              if flag := flags.Lookup(key); flag == nil && !skipValidateOptions[key] {
      Severity: Minor
      Found in daemon/config/config.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 Sandbox.populateNetworkResources has 68 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (sb *Sandbox) populateNetworkResources(ctx context.Context, ep *Endpoint) error {
          ctx, span := otel.Tracer("").Start(ctx, "libnetwork.Sandbox.populateNetworkResources", trace.WithAttributes(
              attribute.String("endpoint.Name", ep.Name())))
          defer span.End()
      
      
      Severity: Minor
      Found in libnetwork/sandbox_linux.go - About 1 hr to fix

        Function newAWSLogsClient has 68 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func newAWSLogsClient(info logger.Info, configOpts ...func(*config.LoadOptions) error) (*cloudwatchlogs.Client, error) {
            ctx := context.TODO()
            var region, endpoint *string
            if os.Getenv(regionEnvKey) != "" {
                region = aws.String(os.Getenv(regionEnvKey))
        Severity: Minor
        Found in daemon/logger/awslogs/cloudwatchlogs.go - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language