dotcloud/docker

View on GitHub

Showing 1,904 of 1,904 total issues

Function validateEndpointSettings has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
Open

func validateEndpointSettings(nw *libnetwork.Network, nwName string, epConfig *networktypes.EndpointSettings) error {
    if epConfig == 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

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

func (c *Cluster) CreateConfig(s types.ConfigSpec) (string, error) {
    var resp *swarmapi.CreateConfigResponse
    if err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
        configSpec := convert.ConfigSpecToGRPC(s)

Severity: Major
Found in daemon/cluster/configs.go and 1 other location - About 2 hrs to fix
daemon/cluster/secrets.go on lines 67..83

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

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) CreateSecret(s types.SecretSpec) (string, error) {
    var resp *swarmapi.CreateSecretResponse
    if err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
        secretSpec := convert.SecretSpecToGRPC(s)

Severity: Major
Found in daemon/cluster/secrets.go and 1 other location - About 2 hrs to fix
daemon/cluster/configs.go on lines 66..82

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

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 addrSpace.allocatePredefinedPool has 77 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (aSpace *addrSpace) allocatePredefinedPool(reserved []netip.Prefix) (netip.Prefix, error) {
    aSpace.mu.Lock()
    defer aSpace.mu.Unlock()

    var pdfID int
Severity: Major
Found in libnetwork/ipams/defaultipam/address_space.go - About 2 hrs to fix

    Method Network.addLBBackend has 77 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (n *Network) addLBBackend(ip net.IP, lb *loadBalancer) {
        if len(lb.vip) == 0 {
            return
        }
    
    
    Severity: Major
    Found in libnetwork/service_windows.go - About 2 hrs to fix

      Method distributionRouter.fetchManifest has 77 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (s *distributionRouter) fetchManifest(ctx context.Context, distrepo distribution.Repository, namedRef reference.Named) (registry.DistributionInspect, error) {
          var distributionInspect registry.DistributionInspect
          if canonicalRef, ok := namedRef.(reference.Canonical); !ok {
              namedRef = reference.TagNameOnly(namedRef)
      
      
      Severity: Major
      Found in api/server/router/distribution/distribution_routes.go - About 2 hrs to fix

        Method Daemon.setupMounts has 77 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (daemon *Daemon) setupMounts(ctx context.Context, c *container.Container) ([]container.Mount, func(context.Context) error, error) {
            var mounts []container.Mount
            // TODO: tmpfs mounts should be part of Mountpoints
            tmpfsMounts := make(map[string]bool)
            tmpfsMountInfo, err := c.TmpfsMounts()
        Severity: Major
        Found in daemon/volumes_unix.go - About 2 hrs to fix

          Method container.NewTask has 77 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (c *container) NewTask(ctx context.Context, checkpointDir string, withStdin bool, attachStdio libcontainerdtypes.StdioCallback) (libcontainerdtypes.Task, error) {
              var (
                  checkpoint     *types.Descriptor
                  t              containerd.Task
                  rio            cio.IO
          Severity: Major
          Found in libcontainerd/remote/client.go - About 2 hrs to fix

            File container.go has 503 lines of code (exceeds 500 allowed). Consider refactoring.
            Open

            package convert // import "github.com/docker/docker/daemon/cluster/convert"
            
            import (
                "context"
                "encoding/json"
            Severity: Minor
            Found in daemon/cluster/convert/container.go - About 2 hrs to fix

              Function skipAgent has 76 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func skipAgent(dAtA []byte) (n int, err error) {
                  l := len(dAtA)
                  iNdEx := 0
                  depth := 0
                  for iNdEx < l {
              Severity: Major
              Found in libnetwork/agent.pb.go - About 2 hrs to fix

                Method Controller.handleEpTableEvent has 76 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (c *Controller) handleEpTableEvent(ev events.Event) {
                    var (
                        nid   string
                        eid   string
                        value []byte
                Severity: Major
                Found in libnetwork/agent.go - About 2 hrs to fix

                  Function skipOverlay has 76 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func skipOverlay(dAtA []byte) (n int, err error) {
                      l := len(dAtA)
                      iNdEx := 0
                      depth := 0
                      for iNdEx < l {
                  Severity: Major
                  Found in libnetwork/drivers/overlay/overlay.pb.go - About 2 hrs to fix

                    Method driver.createNetwork has 76 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (d *driver) createNetwork(config *networkConfiguration) (err error) {
                        // Initialize handle when needed
                        d.Lock()
                        if d.nlh.Handle == nil {
                            d.nlh = ns.NlHandle()
                    Severity: Major
                    Found in libnetwork/drivers/bridge/bridge_linux.go - About 2 hrs to fix

                      Function skipNetworkdb has 76 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func skipNetworkdb(dAtA []byte) (n int, err error) {
                          l := len(dAtA)
                          iNdEx := 0
                          depth := 0
                          for iNdEx < l {
                      Severity: Major
                      Found in libnetwork/networkdb/networkdb.pb.go - About 2 hrs to fix

                        Method networkRouter.getNetwork has 76 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (n *networkRouter) getNetwork(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/network/network_routes.go - About 2 hrs to fix

                          Function skipPlugin has 76 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func skipPlugin(dAtA []byte) (n int, err error) {
                              l := len(dAtA)
                              iNdEx := 0
                              depth := 0
                              for iNdEx < l {
                          Severity: Major
                          Found in api/types/swarm/runtime/plugin.pb.go - About 2 hrs to fix

                            Function skipEntry has 76 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func skipEntry(dAtA []byte) (n int, err error) {
                                l := len(dAtA)
                                iNdEx := 0
                                depth := 0
                                for iNdEx < l {
                            Severity: Major
                            Found in api/types/plugins/logdriver/entry.pb.go - About 2 hrs to fix

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

                                      if len(n.config.Ipv6Subnets) > 0 {
                                          s := n.getSubnetforIPv6(ep.addrv6)
                                          if s == nil {
                                              return fmt.Errorf("could not find a valid ipv6 subnet for endpoint %s", eid)
                                          }
                              Severity: Major
                              Found in libnetwork/drivers/macvlan/macvlan_joinleave.go and 3 other locations - About 2 hrs to fix
                              libnetwork/drivers/ipvlan/ipvlan_joinleave.go on lines 93..108
                              libnetwork/drivers/ipvlan/ipvlan_joinleave.go on lines 110..125
                              libnetwork/drivers/macvlan/macvlan_joinleave.go on lines 53..68

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

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

                                      if len(n.config.Ipv4Subnets) > 0 {
                                          s := n.getSubnetforIPv4(ep.addr)
                                          if s == nil {
                                              return fmt.Errorf("could not find a valid ipv4 subnet for endpoint %s", eid)
                                          }
                              Severity: Major
                              Found in libnetwork/drivers/macvlan/macvlan_joinleave.go and 3 other locations - About 2 hrs to fix
                              libnetwork/drivers/ipvlan/ipvlan_joinleave.go on lines 93..108
                              libnetwork/drivers/ipvlan/ipvlan_joinleave.go on lines 110..125
                              libnetwork/drivers/macvlan/macvlan_joinleave.go on lines 70..85

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

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

                                          if len(n.config.Ipv4Subnets) > 0 {
                                              s := n.getSubnetforIPv4(ep.addr)
                                              if s == nil {
                                                  return fmt.Errorf("could not find a valid ipv4 subnet for endpoint %s", eid)
                                              }
                              Severity: Major
                              Found in libnetwork/drivers/ipvlan/ipvlan_joinleave.go and 3 other locations - About 2 hrs to fix
                              libnetwork/drivers/ipvlan/ipvlan_joinleave.go on lines 110..125
                              libnetwork/drivers/macvlan/macvlan_joinleave.go on lines 53..68
                              libnetwork/drivers/macvlan/macvlan_joinleave.go on lines 70..85

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

                              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

                              Severity
                              Category
                              Status
                              Source
                              Language