dotcloud/docker

View on GitHub

Showing 1,904 of 1,904 total issues

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/ipvlan/ipvlan_joinleave.go and 3 other locations - About 2 hrs to fix
libnetwork/drivers/ipvlan/ipvlan_joinleave.go on lines 93..108
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

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

func (sr *swarmRouter) getConfigs(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
    if err := httputils.ParseForm(r); err != nil {
        return err
    }
    filters, err := filters.FromJSON(r.Form.Get("filters"))
Severity: Major
Found in api/server/router/swarm/cluster_routes.go and 1 other location - About 2 hrs to fix
api/server/router/swarm/cluster_routes.go on lines 418..433

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

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 (sr *swarmRouter) getSecrets(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
    if err := httputils.ParseForm(r); err != nil {
        return err
    }
    filters, err := filters.FromJSON(r.Form.Get("filters"))
Severity: Major
Found in api/server/router/swarm/cluster_routes.go and 1 other location - About 2 hrs to fix
api/server/router/swarm/cluster_routes.go on lines 489..504

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

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 tarexporter.Load has 22 return statements (exceeds 4 allowed).
Open

func (l *tarexporter) Load(ctx context.Context, inTar io.ReadCloser, outStream io.Writer, quiet bool) (outErr error) {
    ctx, span := tracing.StartSpan(ctx, "tarexport.Load")
    defer span.End()
    defer func() {
        span.SetStatus(outErr)
Severity: Major
Found in image/tarexport/load.go - About 2 hrs to fix

    Method NetworkDB.bulkSyncNode has 75 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (nDB *NetworkDB) bulkSyncNode(networks []string, node string, unsolicited bool) error {
        var msgs [][]byte
    
        var unsolMsg string
        if unsolicited {
    Severity: Minor
    Found in libnetwork/networkdb/cluster.go - About 2 hrs to fix

      Method windowsParser.validateMountConfigReg has 75 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (p *windowsParser) validateMountConfigReg(mnt *mount.Mount, additionalValidators ...mountValidator) error {
          if len(mnt.Target) == 0 {
              return &errMountConfig{mnt, errMissingField("Target")}
          }
          for _, v := range additionalValidators {
      Severity: Minor
      Found in volume/mounts/windows_parser.go - About 2 hrs to fix

        Method executor.Describe has 75 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) {
            info, err := e.backend.SystemInfo(ctx)
            if err != nil {
                return nil, err
            }
        Severity: Minor
        Found in daemon/cluster/executor/container/executor.go - About 2 hrs to fix

          Method ImageService.LoadImage has 75 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (i *ImageService) LoadImage(ctx context.Context, inTar io.ReadCloser, platform *ocispec.Platform, outStream io.Writer, quiet bool) error {
              decompressed, err := dockerarchive.DecompressStream(inTar)
              if err != nil {
                  return errors.Wrap(err, "failed to decompress input tar archive")
              }
          Severity: Minor
          Found in daemon/containerd/image_exporter.go - About 2 hrs to fix

            Function volumeSpecToGRPC has 75 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func volumeSpecToGRPC(spec volumetypes.ClusterVolumeSpec) *swarmapi.VolumeSpec {
                swarmSpec := &swarmapi.VolumeSpec{
                    Group: spec.Group,
                }
            
            
            Severity: Minor
            Found in daemon/cluster/convert/volume.go - About 2 hrs to fix

              Method tarSum.Read has 75 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (ts *tarSum) Read(buf []byte) (int, error) {
                  if ts.finished {
                      return ts.bufWriter.Read(buf)
                  }
                  if len(ts.bufData) < len(buf) {
              Severity: Minor
              Found in pkg/tarsum/tarsum.go - About 2 hrs to fix

                Method Daemon.fillRootlessVersion has 75 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (daemon *Daemon) fillRootlessVersion(ctx context.Context, v *types.Version) error {
                    if !rootless.RunningWithRootlessKit() {
                        return nil
                    }
                    rlc, err := getRootlessKitClient()
                Severity: Minor
                Found in daemon/info_unix.go - About 2 hrs to fix

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

                  func (d *Daemon) CheckPluginRunning(ctx context.Context, plugin string) func(c *testing.T) (interface{}, string) {
                      return func(c *testing.T) (interface{}, string) {
                          apiclient := d.NewClientT(c)
                          resp, _, err := apiclient.PluginInspectWithRaw(ctx, plugin)
                          if errdefs.IsNotFound(err) {
                  Severity: Major
                  Found in integration-cli/daemon/daemon_swarm.go and 1 other location - About 2 hrs to fix
                  integration-cli/daemon/daemon_swarm.go on lines 80..90

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

                  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 (d *Daemon) CheckPluginImage(ctx context.Context, plugin string) func(c *testing.T) (interface{}, string) {
                      return func(c *testing.T) (interface{}, string) {
                          apiclient := d.NewClientT(c)
                          resp, _, err := apiclient.PluginInspectWithRaw(ctx, plugin)
                          if errdefs.IsNotFound(err) {
                  Severity: Major
                  Found in integration-cli/daemon/daemon_swarm.go and 1 other location - About 2 hrs to fix
                  integration-cli/daemon/daemon_swarm.go on lines 67..77

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

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

                  func withFetchProgress(cs content.Store, out progress.Output, ref reference.Named) images.HandlerFunc {
                      return func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
                          switch desc.MediaType {
                          case ocispec.MediaTypeImageManifest, images.MediaTypeDockerSchema2Manifest:
                              tn := reference.TagNameOnly(ref)
                  Severity: Minor
                  Found in plugin/fetch_linux.go - About 1 hr to fix

                    Method Resolver.serveDNS has 74 lines of code (exceeds 50 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

                      Method Daemon.getInspectData has 73 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (daemon *Daemon) getInspectData(daemonCfg *config.Config, container *container.Container) (*containertypes.ContainerJSONBase, error) {
                          // make a copy to play with
                          hostConfig := *container.HostConfig
                      
                          children := daemon.children(container)
                      Severity: Minor
                      Found in daemon/inspect.go - About 1 hr to fix

                        Method puller.pullManifestList has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func (p *puller) pullManifestList(ctx context.Context, ref reference.Named, mfstList *manifestlist.DeserializedManifestList, pp *ocispec.Platform) (id digest.Digest, manifestListDigest digest.Digest, err error) {
                            manifestListDigest, err = schema2ManifestDigest(ref, mfstList)
                            if err != nil {
                                return "", "", err
                            }
                        Severity: Minor
                        Found in distribution/pull_v2.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 Controller.NewNetwork has 21 return statements (exceeds 4 allowed).
                        Open

                        func (c *Controller) NewNetwork(networkType, name string, id string, options ...NetworkOption) (_ *Network, retErr error) {
                            if id != "" {
                                c.networkLocker.Lock(id)
                                defer c.networkLocker.Unlock(id) //nolint:errcheck
                        
                        
                        Severity: Major
                        Found in libnetwork/controller.go - About 1 hr to fix

                          Method driver.Join has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func (d *driver) Join(_ context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) (retErr error) {
                              join := &api.JoinRequest{
                                  NetworkID:  nid,
                                  EndpointID: eid,
                                  SandboxKey: sboxKey,
                          Severity: Minor
                          Found in libnetwork/drivers/remote/driver.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.CreateEndpoint has 21 return statements (exceeds 4 allowed).
                          Open

                          func (d *driver) CreateEndpoint(ctx context.Context, nid, eid string, ifInfo driverapi.InterfaceInfo, _ map[string]interface{}) error {
                              if ifInfo == nil {
                                  return errors.New("invalid interface info passed")
                              }
                          
                          
                          Severity: Major
                          Found in libnetwork/drivers/bridge/bridge_linux.go - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language