dotcloud/docker

View on GitHub
distribution/push_v2.go

Summary

Maintainability
D
3 days
Test Coverage

Method pushDescriptor.Upload has a Cognitive Complexity of 57 (exceeds 20 allowed). Consider refactoring.
Open

func (pd *pushDescriptor) Upload(ctx context.Context, progressOutput progress.Output) (distribution.Descriptor, error) {
    // Skip foreign layers unless this registry allows nondistributable artifacts.
    if !pd.endpoint.AllowNondistributableArtifacts {
        if fs, ok := pd.layer.(distribution.Describable); ok {
            if d := fs.Descriptor(); len(d.URLs) > 0 {
Severity: Minor
Found in distribution/push_v2.go - About 6 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 pushDescriptor.Upload has 112 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (pd *pushDescriptor) Upload(ctx context.Context, progressOutput progress.Output) (distribution.Descriptor, error) {
    // Skip foreign layers unless this registry allows nondistributable artifacts.
    if !pd.endpoint.AllowNondistributableArtifacts {
        if fs, ok := pd.layer.(distribution.Describable); ok {
            if d := fs.Descriptor(); len(d.URLs) > 0 {
Severity: Major
Found in distribution/push_v2.go - About 3 hrs to fix

    File push_v2.go has 555 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package distribution // import "github.com/docker/docker/distribution"
    
    import (
        "context"
        "fmt"
    Severity: Minor
    Found in distribution/push_v2.go - About 3 hrs to fix

      Method pusher.pushTag has 99 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (p *pusher) pushTag(ctx context.Context, ref reference.NamedTagged, id digest.Digest) error {
          log.G(ctx).Debugf("Pushing repository: %s", reference.FamiliarString(ref))
      
          imgConfig, err := p.config.ImageStore.Get(ctx, id)
          if err != nil {
      Severity: Major
      Found in distribution/push_v2.go - About 2 hrs to fix

        Method pusher.pushTag has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
        Open

        func (p *pusher) pushTag(ctx context.Context, ref reference.NamedTagged, id digest.Digest) error {
            log.G(ctx).Debugf("Pushing repository: %s", reference.FamiliarString(ref))
        
            imgConfig, err := p.config.ImageStore.Get(ctx, id)
            if err != nil {
        Severity: Minor
        Found in distribution/push_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 pusher.pushTag has 17 return statements (exceeds 4 allowed).
        Open

        func (p *pusher) pushTag(ctx context.Context, ref reference.NamedTagged, id digest.Digest) error {
            log.G(ctx).Debugf("Pushing repository: %s", reference.FamiliarString(ref))
        
            imgConfig, err := p.config.ImageStore.Get(ctx, id)
            if err != nil {
        Severity: Major
        Found in distribution/push_v2.go - About 1 hr to fix

          Method pushDescriptor.layerAlreadyExists has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
          Open

          func (pd *pushDescriptor) layerAlreadyExists(
              ctx context.Context,
              progressOutput progress.Output,
              diffID layer.DiffID,
              checkOtherRepositories bool,
          Severity: Minor
          Found in distribution/push_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 pushDescriptor.layerAlreadyExists has 58 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (pd *pushDescriptor) layerAlreadyExists(
              ctx context.Context,
              progressOutput progress.Output,
              diffID layer.DiffID,
              checkOtherRepositories bool,
          Severity: Minor
          Found in distribution/push_v2.go - About 1 hr to fix

            Method pushDescriptor.Upload has 8 return statements (exceeds 4 allowed).
            Open

            func (pd *pushDescriptor) Upload(ctx context.Context, progressOutput progress.Output) (distribution.Descriptor, error) {
                // Skip foreign layers unless this registry allows nondistributable artifacts.
                if !pd.endpoint.AllowNondistributableArtifacts {
                    if fs, ok := pd.layer.(distribution.Describable); ok {
                        if d := fs.Descriptor(); len(d.URLs) > 0 {
            Severity: Major
            Found in distribution/push_v2.go - About 50 mins to fix

              Method pushDescriptor.layerAlreadyExists has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  ctx context.Context,
                  progressOutput progress.Output,
                  diffID layer.DiffID,
                  checkOtherRepositories bool,
                  maxExistenceCheckAttempts int,
              Severity: Minor
              Found in distribution/push_v2.go - About 45 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 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

                    There are no issues that match your filters.

                    Category
                    Status