dotcloud/docker

View on GitHub

Showing 1,904 of 1,904 total issues

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

func (ep *endpoint) MarshalJSON() ([]byte, error) {
    epMap := make(map[string]interface{})
    epMap["id"] = ep.id
    epMap["nid"] = ep.nid
    epMap["SrcName"] = ep.srcName
Severity: Major
Found in libnetwork/drivers/ipvlan/ipvlan_store.go and 1 other location - About 2 hrs to fix
libnetwork/drivers/macvlan/macvlan_store.go on lines 239..254

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

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

        case 3:
            if wireType != 2 {
                return fmt.Errorf("proto: wrong wireType = %d for field TunnelEndpointIP", wireType)
            }
            var stringLen uint64
Severity: Major
Found in libnetwork/drivers/windows/overlay/overlay.pb.go and 2 other locations - About 2 hrs to fix
libnetwork/drivers/windows/overlay/overlay.pb.go on lines 224..252
libnetwork/drivers/windows/overlay/overlay.pb.go on lines 253..281

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

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

    switch {
    case service.TaskTemplate.ContainerSpec != nil:
        if taggedImg := imageWithTagString(service.TaskTemplate.ContainerSpec.Image); taggedImg != "" {
            service.TaskTemplate.ContainerSpec.Image = taggedImg
        }
Severity: Major
Found in client/service_create.go and 1 other location - About 2 hrs to fix
client/service_update.go on lines 47..62

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

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

    switch {
    case service.TaskTemplate.ContainerSpec != nil:
        if taggedImg := imageWithTagString(service.TaskTemplate.ContainerSpec.Image); taggedImg != "" {
            service.TaskTemplate.ContainerSpec.Image = taggedImg
        }
Severity: Major
Found in client/service_update.go and 1 other location - About 2 hrs to fix
client/service_create.go on lines 43..58

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

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 (c *Cluster) UpdateSecret(input string, version uint64, spec types.SecretSpec) error {
    return c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
        secret, err := getSecret(ctx, state.controlClient, input)
        if err != nil {
            return err
Severity: Major
Found in daemon/cluster/secrets.go and 1 other location - About 2 hrs to fix
daemon/cluster/configs.go on lines 103..122

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

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

    err := imageFilters.WalkValues("before", func(value string) error {
        img, err := i.GetImage(ctx, value, backend.GetImageOpts{})
        if err != nil {
            return err
        }
Severity: Major
Found in daemon/containerd/image_list.go and 1 other location - About 2 hrs to fix
daemon/containerd/image_list.go on lines 544..559

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

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 (c *Cluster) UpdateConfig(input string, version uint64, spec types.ConfigSpec) error {
    return c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
        config, err := getConfig(ctx, state.controlClient, input)
        if err != nil {
            return err
Severity: Major
Found in daemon/cluster/configs.go and 1 other location - About 2 hrs to fix
daemon/cluster/secrets.go on lines 104..123

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

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

    err = imageFilters.WalkValues("since", func(value string) error {
        img, err := i.GetImage(ctx, value, backend.GetImageOpts{})
        if err != nil {
            return err
        }
Severity: Major
Found in daemon/containerd/image_list.go and 1 other location - About 2 hrs to fix
daemon/containerd/image_list.go on lines 524..539

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

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

Function setupSeccomp has 78 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func setupSeccomp(config *Seccomp, rs *specs.Spec) (*specs.LinuxSeccomp, error) {
    if config == nil {
        return nil, nil
    }

Severity: Major
Found in profiles/seccomp/seccomp_linux.go - About 2 hrs to fix

    Method systemRouter.getEvents has 78 lines of code (exceeds 50 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: Major
    Found in api/server/router/system/system_routes.go - About 2 hrs to fix

      Function setupLabelFilter has 78 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func setupLabelFilter(ctx context.Context, store content.Store, fltrs filters.Args) (func(image images.Image) bool, error) {
          type labelCheck struct {
              key        string
              value      string
              onlyExists bool
      Severity: Major
      Found in daemon/containerd/image_list.go - About 2 hrs to fix

        Function New has 78 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func New(info logger.Info) (logger.Logger, error) {
            initGCP()
        
            var project string
            if projectID != "" {
        Severity: Major
        Found in daemon/logger/gcplogs/gcplogging.go - About 2 hrs to fix

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

          func (r *Resolver) setupIPTable() error {
              if r.err != nil {
                  return r.err
              }
              laddr := r.conn.LocalAddr().String()
          Severity: Minor
          Found in libnetwork/resolver_unix.go - About 2 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 Network.addLBBackend has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
          Open

          func (n *Network) addLBBackend(ip net.IP, lb *loadBalancer) {
              if len(lb.vip) == 0 {
                  return
              }
          
          
          Severity: Minor
          Found in libnetwork/service_windows.go - About 2 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 setupIPChains has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
          Open

          func setupIPChains(config configuration, version iptables.IPVersion) (natChain *iptables.ChainInfo, filterChain *iptables.ChainInfo, isolationChain1 *iptables.ChainInfo, isolationChain2 *iptables.ChainInfo, retErr error) {
              // Sanity check.
              if version == iptables.IPv4 && !config.EnableIPTables {
                  return nil, nil, nil, nil, errors.New("cannot create new chains, iptables is disabled")
              }
          Severity: Minor
          Found in libnetwork/drivers/bridge/setup_ip_tables_linux.go - About 2 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.setupFilters has 23 return statements (exceeds 4 allowed).
          Open

          func (i *ImageService) setupFilters(ctx context.Context, imageFilters filters.Args) (filterFunc imageFilterFunc, outErr error) {
              var fltrs []imageFilterFunc
              err := imageFilters.WalkValues("before", func(value string) error {
                  img, err := i.GetImage(ctx, value, backend.GetImageOpts{})
                  if err != nil {
          Severity: Major
          Found in daemon/containerd/image_list.go - About 2 hrs to fix

            Method ImageService.deleteAll has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
            Open

            func (i *ImageService) deleteAll(ctx context.Context, imgID image.ID, all []images.Image, c conflictType, prune bool) (records []imagetypes.DeleteResponse, err error) {
                // Workaround for: https://github.com/moby/buildkit/issues/3797
                possiblyDeletedConfigs := map[digest.Digest]struct{}{}
                if len(all) > 0 && i.content != nil {
                    handled := map[digest.Digest]struct{}{}
            Severity: Minor
            Found in daemon/containerd/image_delete.go - About 2 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 Cluster.Leave has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
            Open

            func (c *Cluster) Leave(ctx context.Context, force bool) error {
                c.controlMutex.Lock()
                defer c.controlMutex.Unlock()
            
                c.mu.Lock()
            Severity: Minor
            Found in daemon/cluster/swarm.go - About 2 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.allocateNetwork has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
            Open

            func (daemon *Daemon) allocateNetwork(ctx context.Context, cfg *config.Config, ctr *container.Container) (retErr error) {
                if daemon.netController == nil {
                    return nil
                }
            
            
            Severity: Minor
            Found in daemon/container_operations.go - About 2 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 DirCopy has 23 return statements (exceeds 4 allowed).
            Open

            func DirCopy(srcDir, dstDir string, copyMode Mode, copyOpaqueXattrs bool) error {
                copyWithFileRange := true
                copyWithFileClone := true
            
                // This is a map of source file inodes to dst file paths
            Severity: Major
            Found in daemon/graphdriver/copy/copy.go - About 2 hrs to fix
              Severity
              Category
              Status
              Source
              Language