dotcloud/docker

View on GitHub

Showing 1,904 of 1,904 total issues

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

func (ir *imageRouter) postImagesPrune(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
    if err := httputils.ParseForm(r); err != nil {
        return err
    }

Severity: Major
Found in api/server/router/image/image_routes.go and 2 other locations - About 1 hr to fix
api/server/router/network/network_routes.go on lines 295..310
api/server/router/container/container_routes.go on lines 1057..1072

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

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 createDummyLink(dummyName, truncNetID string) error {
    // create a parent interface since one was not specified
    parent := &netlink.Dummy{
        LinkAttrs: netlink.LinkAttrs{
            Name: dummyName,
Severity: Major
Found in libnetwork/drivers/macvlan/macvlan_setup.go and 1 other location - About 1 hr to fix
libnetwork/drivers/ipvlan/ipvlan_setup.go on lines 182..202

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

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 createDummyLink(dummyName, truncNetID string) error {
    // create a parent interface since one was not specified
    parent := &netlink.Dummy{
        LinkAttrs: netlink.LinkAttrs{
            Name: dummyName,
Severity: Major
Found in libnetwork/drivers/ipvlan/ipvlan_setup.go and 1 other location - About 1 hr to fix
libnetwork/drivers/macvlan/macvlan_setup.go on lines 162..182

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

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

func (i *ImageService) LogImageEvent(imageID, refName string, action events.Action) {
    ctx := context.TODO()
    attributes := map[string]string{}

    img, err := i.GetImage(ctx, imageID, backend.GetImageOpts{})
Severity: Major
Found in daemon/images/image_events.go and 1 other location - About 1 hr to fix
daemon/containerd/image_events.go on lines 12..29

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

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

func (i *ImageService) LogImageEvent(imageID, refName string, action events.Action) {
    ctx := context.TODO()
    attributes := map[string]string{}

    img, err := i.GetImage(ctx, imageID, backend.GetImageOpts{})
Severity: Major
Found in daemon/containerd/image_events.go and 1 other location - About 1 hr to fix
daemon/images/image_events.go on lines 11..28

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

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 (nr *Networks) WalkDrivers(dfn DriverWalkFunc) {
    type driverVal struct {
        name string
        data driverData
    }
Severity: Major
Found in libnetwork/drvregistry/networks.go and 1 other location - About 1 hr to fix
libnetwork/drvregistry/ipams.go on lines 66..84

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

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 (ir *IPAMs) WalkIPAMs(ifn IPAMWalkFunc) {
    type ipamVal struct {
        name string
        data ipamDriver
    }
Severity: Major
Found in libnetwork/drvregistry/ipams.go and 1 other location - About 1 hr to fix
libnetwork/drvregistry/networks.go on lines 32..50

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

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 Daemon.containerAttach has 70 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (daemon *Daemon) containerAttach(c *container.Container, cfg *stream.AttachConfig, logs, doStream bool) error {
    if logs {
        logDriver, logCreated, err := daemon.getLogger(c)
        if err != nil {
            return err
Severity: Minor
Found in daemon/attach.go - About 1 hr to fix

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

    func (this *NodeEvent) GoString() string {
        if this == nil {
            return "nil"
        }
        s := make([]string, 0, 7)
    Severity: Major
    Found in libnetwork/networkdb/networkdb.pb.go and 2 other locations - About 1 hr to fix
    libnetwork/drivers/windows/overlay/overlay.pb.go on lines 79..90
    libnetwork/drivers/overlay/overlay.pb.go on lines 121..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 177.

    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 3 locations. Consider refactoring.
    Open

    func (this *PeerRecord) GoString() string {
        if this == nil {
            return "nil"
        }
        s := make([]string, 0, 7)
    Severity: Major
    Found in libnetwork/drivers/overlay/overlay.pb.go and 2 other locations - About 1 hr to fix
    libnetwork/drivers/windows/overlay/overlay.pb.go on lines 79..90
    libnetwork/networkdb/networkdb.pb.go on lines 839..850

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

    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 3 locations. Consider refactoring.
    Open

    func (this *PeerRecord) GoString() string {
        if this == nil {
            return "nil"
        }
        s := make([]string, 0, 7)
    Severity: Major
    Found in libnetwork/drivers/windows/overlay/overlay.pb.go and 2 other locations - About 1 hr to fix
    libnetwork/drivers/overlay/overlay.pb.go on lines 121..132
    libnetwork/networkdb/networkdb.pb.go on lines 839..850

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

    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

        for _, ep := range n.endpoints {
            if link, err := ns.NlHandle().LinkByName(ep.srcName); err == nil {
                if err := ns.NlHandle().LinkDel(link); err != nil {
                    log.G(context.TODO()).WithError(err).Warnf("Failed to delete interface (%s)'s link on endpoint (%s) delete", ep.srcName, ep.id)
                }
    Severity: Major
    Found in libnetwork/drivers/macvlan/macvlan_network.go and 1 other location - About 1 hr to fix
    libnetwork/drivers/ipvlan/ipvlan_network.go on lines 153..163

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

    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

        for _, ep := range n.endpoints {
            if link, err := ns.NlHandle().LinkByName(ep.srcName); err == nil {
                if err := ns.NlHandle().LinkDel(link); err != nil {
                    log.G(context.TODO()).WithError(err).Warnf("Failed to delete interface (%s)'s link on endpoint (%s) delete", ep.srcName, ep.id)
                }
    Severity: Major
    Found in libnetwork/drivers/ipvlan/ipvlan_network.go and 1 other location - About 1 hr to fix
    libnetwork/drivers/macvlan/macvlan_network.go on lines 173..183

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

    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

    func oneOffProgress(ctx context.Context, id string) func(err error) error {
        pw, _, _ := progress.NewFromContext(ctx)
        now := time.Now()
        st := progress.Status{
            Started: &now,
    Severity: Major
    Found in builder/builder-next/worker/worker.go and 1 other location - About 1 hr to fix
    builder/builder-next/exporter/mobyexporter/writer.go on lines 209..224

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

    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

    func oneOffProgress(ctx context.Context, id string) func(err error) error {
        pw, _, _ := progress.NewFromContext(ctx)
        now := time.Now()
        st := progress.Status{
            Started: &now,
    Severity: Major
    Found in builder/builder-next/exporter/mobyexporter/writer.go and 1 other location - About 1 hr to fix
    builder/builder-next/worker/worker.go on lines 552..567

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

    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 containerAdapter.pullImage has 69 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (c *containerAdapter) pullImage(ctx context.Context) error {
        spec := c.container.spec()
    
        // Skip pulling if the image is referenced by image ID.
        if _, err := digest.Parse(spec.Image); err == nil {
    Severity: Minor
    Found in daemon/cluster/executor/container/adapter.go - About 1 hr to fix

      Function buildCreateEndpointOptions has 69 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func buildCreateEndpointOptions(c *container.Container, n *libnetwork.Network, epConfig *network.EndpointSettings, sb *libnetwork.Sandbox, daemonDNS []string) ([]libnetwork.EndpointOption, error) {
          var createOptions []libnetwork.EndpointOption
          genericOptions := make(options.Generic)
      
          nwName := n.Name()
      Severity: Minor
      Found in daemon/network.go - About 1 hr to fix

        Function StdCopy has 69 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error) {
            var (
                buf       = make([]byte, startingBufLen)
                bufLen    = len(buf)
                nr, nw    int
        Severity: Minor
        Found in pkg/stdcopy/stdcopy.go - About 1 hr to fix

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