dotcloud/docker

View on GitHub

Showing 1,904 of 1,904 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 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.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 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 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

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 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

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

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

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

    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

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            return filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
                if err != nil {
                    return err
                }
    
    
    Severity: Major
    Found in daemon/containerd/image_snapshot_unix.go and 1 other location - About 1 hr to fix
    daemon/containerd/image_snapshot_unix.go on lines 75..91

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 175.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

                return filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
                    if err != nil {
                        return err
                    }
    
    
    Severity: Major
    Found in daemon/containerd/image_snapshot_unix.go and 1 other location - About 1 hr to fix
    daemon/containerd/image_snapshot_unix.go on lines 98..114

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 175.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (n *bridgeNetwork) setupIP6Tables(config *networkConfiguration, i *bridgeInterface) error {
        d := n.driver
        d.Lock()
        driverConfig := d.config
        d.Unlock()
    Severity: Major
    Found in libnetwork/drivers/bridge/setup_ip_tables_linux.go and 1 other location - About 1 hr to fix
    libnetwork/drivers/bridge/setup_ip_tables_linux.go on lines 116..132

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 174.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (n *bridgeNetwork) setupIP4Tables(config *networkConfiguration, i *bridgeInterface) error {
        d := n.driver
        d.Lock()
        driverConfig := d.config
        d.Unlock()
    Severity: Major
    Found in libnetwork/drivers/bridge/setup_ip_tables_linux.go and 1 other location - About 1 hr to fix
    libnetwork/drivers/bridge/setup_ip_tables_linux.go on lines 134..151

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 174.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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
      Severity
      Category
      Status
      Source
      Language