dotcloud/docker

View on GitHub
daemon/containerd/image_push.go

Summary

Maintainability
D
2 days
Test Coverage

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

func (i *ImageService) pushRef(ctx context.Context, targetRef reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, out progress.Output) (retErr error) {
    leasedCtx, release, err := i.client.WithLease(ctx)
    if err != nil {
        return err
    }
Severity: Minor
Found in daemon/containerd/image_push.go - About 3 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.pushRef has 102 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (i *ImageService) pushRef(ctx context.Context, targetRef reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, out progress.Output) (retErr error) {
    leasedCtx, release, err := i.client.WithLease(ctx)
    if err != nil {
        return err
    }
Severity: Major
Found in daemon/containerd/image_push.go - About 3 hrs to fix

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

    func (i *ImageService) getPushDescriptor(ctx context.Context, img containerdimages.Image, platform *ocispec.Platform) (ocispec.Descriptor, error) {
        pm := i.matchRequestedOrDefault(platforms.OnlyStrict, platform)
    
        anyMissing := false
    
    
    Severity: Minor
    Found in daemon/containerd/image_push.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 ImageService.getPushDescriptor has 61 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (i *ImageService) getPushDescriptor(ctx context.Context, img containerdimages.Image, platform *ocispec.Platform) (ocispec.Descriptor, error) {
        pm := i.matchRequestedOrDefault(platforms.OnlyStrict, platform)
    
        anyMissing := false
    
    
    Severity: Minor
    Found in daemon/containerd/image_push.go - About 1 hr to fix

      Method ImageService.getPushDescriptor has 15 return statements (exceeds 4 allowed).
      Open

      func (i *ImageService) getPushDescriptor(ctx context.Context, img containerdimages.Image, platform *ocispec.Platform) (ocispec.Descriptor, error) {
          pm := i.matchRequestedOrDefault(platforms.OnlyStrict, platform)
      
          anyMissing := false
      
      
      Severity: Major
      Found in daemon/containerd/image_push.go - About 1 hr to fix

        Method ImageService.pushRef has 12 return statements (exceeds 4 allowed).
        Open

        func (i *ImageService) pushRef(ctx context.Context, targetRef reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, out progress.Output) (retErr error) {
            leasedCtx, release, err := i.client.WithLease(ctx)
            if err != nil {
                return err
            }
        Severity: Major
        Found in daemon/containerd/image_push.go - About 1 hr to fix

          Function findMissingMountable has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          func findMissingMountable(ctx context.Context, store content.Store, queue *jobs,
              target ocispec.Descriptor, targetRef reference.Named, limiter *semaphore.Weighted,
          Severity: Minor
          Found in daemon/containerd/image_push.go - About 45 mins to fix

            Method ImageService.PushImage has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            func (i *ImageService) PushImage(ctx context.Context, sourceRef reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) (retErr error) {
            Severity: Minor
            Found in daemon/containerd/image_push.go - About 45 mins to fix

              Method ImageService.pushRef has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func (i *ImageService) pushRef(ctx context.Context, targetRef reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, out progress.Output) (retErr error) {
              Severity: Minor
              Found in daemon/containerd/image_push.go - About 45 mins to fix

                Function findMissingMountable has 7 return statements (exceeds 4 allowed).
                Open

                func findMissingMountable(ctx context.Context, store content.Store, queue *jobs,
                    target ocispec.Descriptor, targetRef reference.Named, limiter *semaphore.Weighted,
                ) (map[digest.Digest]distributionSource, error) {
                    mountableBlobs := map[digest.Digest]distributionSource{}
                    var mutex sync.Mutex
                Severity: Major
                Found in daemon/containerd/image_push.go - About 45 mins to fix

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

                  func (i *ImageService) PushImage(ctx context.Context, sourceRef reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) (retErr error) {
                      start := time.Now()
                      defer func() {
                          if retErr == nil {
                              dimages.ImageActions.WithValues("push").UpdateSince(start)
                  Severity: Minor
                  Found in daemon/containerd/image_push.go - About 35 mins 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.PushImage has 5 return statements (exceeds 4 allowed).
                  Open

                  func (i *ImageService) PushImage(ctx context.Context, sourceRef reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) (retErr error) {
                      start := time.Now()
                      defer func() {
                          if retErr == nil {
                              dimages.ImageActions.WithValues("push").UpdateSince(start)
                  Severity: Major
                  Found in daemon/containerd/image_push.go - About 35 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status