dotcloud/docker

View on GitHub

Showing 1,904 of 1,904 total issues

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

        NetworkSettingsBase: containertypes.NetworkSettingsBase{
            Bridge:                 ctr.NetworkSettings.Bridge,
            SandboxID:              ctr.NetworkSettings.SandboxID,
            SandboxKey:             ctr.NetworkSettings.SandboxKey,
            HairpinMode:            ctr.NetworkSettings.HairpinMode,
Severity: Minor
Found in daemon/inspect.go and 1 other location - About 40 mins to fix
daemon/inspect.go on lines 255..264

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

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 Push has 6 return statements (exceeds 4 allowed).
Open

func Push(ctx context.Context, ref reference.Named, config *ImagePushConfig) error {
    // FIXME: Allow to interrupt current push when new push of same image is done.

    // Resolve the Repository name from fqn to RepositoryInfo
    repoInfo, err := config.RegistryService.ResolveRepository(ref)
Severity: Major
Found in distribution/push.go - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

        if p.OS == "" && p.Architecture == "" && p.Variant == "" && p.OSVersion == "" && p.OSFeatures == nil && p.Features == nil {
    Severity: Major
    Found in distribution/pull_v2.go - About 40 mins to fix

      Function checkValidParent has 6 return statements (exceeds 4 allowed).
      Open

      func checkValidParent(img, parent *image.Image) bool {
          if len(img.History) == 0 && len(parent.History) == 0 {
              return true // having history is not mandatory
          }
          if len(img.History)-len(parent.History) != 1 {
      Severity: Major
      Found in image/tarexport/load.go - About 40 mins to fix

        Function fixManifestLayers has 6 return statements (exceeds 4 allowed).
        Open

        func fixManifestLayers(m *schema1.Manifest) error {
            imgs := make([]*image.V1Image, len(m.FSLayers))
            for i := range m.FSLayers {
                img := &image.V1Image{}
        
        
        Severity: Major
        Found in distribution/pull_v2.go - About 40 mins to fix

          Method pushDescriptor.uploadUsingSession has 6 return statements (exceeds 4 allowed).
          Open

          func (pd *pushDescriptor) uploadUsingSession(
              ctx context.Context,
              progressOutput progress.Output,
              diffID layer.DiffID,
              layerUpload distribution.BlobWriter,
          Severity: Major
          Found in distribution/push_v2.go - About 40 mins to fix

            Method Manager.Remove has 6 return statements (exceeds 4 allowed).
            Open

            func (pm *Manager) Remove(name string, config *backend.PluginRmConfig) error {
                p, err := pm.config.Store.GetV2Plugin(name)
                pm.mu.RLock()
                c := pm.cMap[p]
                pm.mu.RUnlock()
            Severity: Major
            Found in plugin/backend_linux.go - About 40 mins to fix

              Function verifySchema1Manifest has 6 return statements (exceeds 4 allowed).
              Open

              func verifySchema1Manifest(signedManifest *schema1.SignedManifest, ref reference.Reference) (m *schema1.Manifest, err error) {
                  // If pull by digest, then verify the manifest digest. NOTE: It is
                  // important to do this first, before any other content validation. If the
                  // digest cannot be verified, don't even bother with those other things.
                  if digested, isCanonical := ref.(reference.Canonical); isCanonical {
              Severity: Major
              Found in distribution/pull_v2.go - About 40 mins to fix

                Function pullEndpoints has 6 return statements (exceeds 4 allowed).
                Open

                func pullEndpoints(ctx context.Context, registryService RegistryResolver, ref reference.Named,
                    f func(context.Context, registry.RepositoryInfo, registry.APIEndpoint) error,
                ) (*registry.RepositoryInfo, error) {
                    // Resolve the Repository name from fqn to RepositoryInfo
                    repoInfo, err := registryService.ResolveRepository(ref)
                Severity: Major
                Found in distribution/pull.go - About 40 mins to fix

                  Method puller.pullRepository has 6 return statements (exceeds 4 allowed).
                  Open

                  func (p *puller) pullRepository(ctx context.Context, ref reference.Named) (err error) {
                      var layersDownloaded bool
                      if !reference.IsNameOnly(ref) {
                          layersDownloaded, err = p.pullTag(ctx, ref, p.config.Platform)
                          if err != nil {
                  Severity: Major
                  Found in distribution/pull_v2.go - About 40 mins to fix

                    Function parseTCPAddr has 6 return statements (exceeds 4 allowed).
                    Open

                    func parseTCPAddr(address string, strict bool) (*url.URL, error) {
                        if !strict && !strings.Contains(address, "://") {
                            address = "tcp://" + address
                        }
                        parsedURL, err := url.Parse(address)
                    Severity: Major
                    Found in opts/hosts.go - About 40 mins to fix

                      Method pusher.pushRepository has 6 return statements (exceeds 4 allowed).
                      Open

                      func (p *pusher) pushRepository(ctx context.Context) (err error) {
                          if namedTagged, isNamedTagged := p.ref.(reference.NamedTagged); isNamedTagged {
                              imageID, err := p.config.ReferenceStore.Get(p.ref)
                              if err != nil {
                                  return fmt.Errorf("tag does not exist: %s", reference.FamiliarString(p.ref))
                      Severity: Major
                      Found in distribution/push_v2.go - About 40 mins to fix

                        Method Sandbox.SetKey has 6 return statements (exceeds 4 allowed).
                        Open

                        func (sb *Sandbox) SetKey(ctx context.Context, basePath string) error {
                            start := time.Now()
                            defer func() {
                                log.G(ctx).Debugf("sandbox set key processing took %s for container %s", time.Since(start), sb.ContainerID())
                            }()
                        Severity: Major
                        Found in libnetwork/sandbox_linux.go - About 40 mins to fix

                          Method EndpointInterface.UnmarshalJSON has 6 return statements (exceeds 4 allowed).
                          Open

                          func (epi *EndpointInterface) UnmarshalJSON(b []byte) error {
                              var (
                                  err   error
                                  epMap map[string]interface{}
                              )
                          Severity: Major
                          Found in libnetwork/endpoint_info.go - About 40 mins to fix

                            Method Controller.handleKeyChange has 6 return statements (exceeds 4 allowed).
                            Open

                            func (c *Controller) handleKeyChange(keys []*types.EncryptionKey) error {
                                drvEnc := discoverapi.DriverEncryptionUpdate{}
                            
                                agent := c.getAgent()
                                if agent == nil {
                            Severity: Major
                            Found in libnetwork/agent.go - About 40 mins to fix

                              Method Sandbox.clearNetworkResources has 6 return statements (exceeds 4 allowed).
                              Open

                              func (sb *Sandbox) clearNetworkResources(origEp *Endpoint) error {
                                  ep := sb.GetEndpoint(origEp.id)
                                  if ep == nil {
                                      return fmt.Errorf("could not find the sandbox endpoint data for endpoint %s",
                                          origEp.id)
                              Severity: Major
                              Found in libnetwork/sandbox.go - About 40 mins to fix

                                Method Endpoint.Delete has 6 return statements (exceeds 4 allowed).
                                Open

                                func (ep *Endpoint) Delete(ctx context.Context, force bool) error {
                                    var err error
                                    n, err := ep.getNetworkFromStore()
                                    if err != nil {
                                        return fmt.Errorf("failed to get network during Delete: %v", err)
                                Severity: Major
                                Found in libnetwork/endpoint.go - About 40 mins to fix

                                  Method IPAMData.UnmarshalJSON has 6 return statements (exceeds 4 allowed).
                                  Open

                                  func (i *IPAMData) UnmarshalJSON(data []byte) error {
                                      var (
                                          m   map[string]interface{}
                                          err error
                                      )
                                  Severity: Major
                                  Found in libnetwork/driverapi/ipamdata.go - About 40 mins to fix

                                    Method Endpoint.deleteServiceInfoFromCluster has 6 return statements (exceeds 4 allowed).
                                    Open

                                    func (ep *Endpoint) deleteServiceInfoFromCluster(sb *Sandbox, fullRemove bool, method string) error {
                                        if len(ep.dnsNames) == 0 {
                                            return nil
                                        }
                                    
                                    
                                    Severity: Major
                                    Found in libnetwork/agent.go - About 40 mins to fix

                                      Method Namespace.AddNeighbor has 6 return statements (exceeds 4 allowed).
                                      Open

                                      func (n *Namespace) AddNeighbor(dstIP net.IP, dstMac net.HardwareAddr, force bool, options ...NeighOption) error {
                                          var (
                                              iface                  netlink.Link
                                              err                    error
                                              neighborAlreadyPresent bool
                                      Severity: Major
                                      Found in libnetwork/osl/neigh_linux.go - About 40 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language