dotcloud/docker

View on GitHub
image/tarexport/load.go

Summary

Maintainability
D
2 days
Test Coverage

Method tarexporter.Load has a Cognitive Complexity of 60 (exceeds 20 allowed). Consider refactoring.
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: Minor
Found in image/tarexport/load.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 tarexporter.Load has 127 lines of code (exceeds 50 allowed). Consider refactoring.
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 4 hrs to fix

    Method tarexporter.legacyLoadImage has 82 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (l *tarexporter) legacyLoadImage(oldID, sourceDir string, loadedMap map[string]image.ID, progressOutput progress.Output) error {
        if _, loaded := loadedMap[oldID]; loaded {
            return nil
        }
        configPath, err := safePath(sourceDir, filepath.Join(oldID, legacyConfigFileName))
    Severity: Major
    Found in image/tarexport/load.go - About 2 hrs to fix

      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 tarexporter.legacyLoadImage has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
        Open

        func (l *tarexporter) legacyLoadImage(oldID, sourceDir string, loadedMap map[string]image.ID, progressOutput progress.Output) error {
            if _, loaded := loadedMap[oldID]; loaded {
                return nil
            }
            configPath, err := safePath(sourceDir, filepath.Join(oldID, legacyConfigFileName))
        Severity: Minor
        Found in image/tarexport/load.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 tarexporter.legacyLoadImage has 15 return statements (exceeds 4 allowed).
        Open

        func (l *tarexporter) legacyLoadImage(oldID, sourceDir string, loadedMap map[string]image.ID, progressOutput progress.Output) error {
            if _, loaded := loadedMap[oldID]; loaded {
                return nil
            }
            configPath, err := safePath(sourceDir, filepath.Join(oldID, legacyConfigFileName))
        Severity: Major
        Found in image/tarexport/load.go - About 1 hr to fix

          Method tarexporter.legacyLoad has 10 return statements (exceeds 4 allowed).
          Open

          func (l *tarexporter) legacyLoad(tmpDir string, outStream io.Writer, progressOutput progress.Output) error {
              if runtime.GOOS == "windows" {
                  return errors.New("Windows does not support legacy loading of images")
              }
          
          
          Severity: Major
          Found in image/tarexport/load.go - About 1 hr to fix

            Method tarexporter.loadLayer has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            func (l *tarexporter) loadLayer(ctx context.Context, filename string, rootFS image.RootFS, id string, foreignSrc distribution.Descriptor, progressOutput progress.Output) (_ layer.Layer, outErr error) {
            Severity: Minor
            Found in image/tarexport/load.go - About 45 mins to fix

              Method tarexporter.legacyLoad has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
              Open

              func (l *tarexporter) legacyLoad(tmpDir string, outStream io.Writer, progressOutput progress.Output) error {
                  if runtime.GOOS == "windows" {
                      return errors.New("Windows does not support legacy loading of images")
                  }
              
              
              Severity: Minor
              Found in image/tarexport/load.go - About 45 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

              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

                Method tarexporter.loadLayer has 5 return statements (exceeds 4 allowed).
                Open

                func (l *tarexporter) loadLayer(ctx context.Context, filename string, rootFS image.RootFS, id string, foreignSrc distribution.Descriptor, progressOutput progress.Output) (_ layer.Layer, outErr error) {
                    ctx, span := tracing.StartSpan(ctx, "loadLayer")
                    span.SetAttributes(tracing.Attribute("image.id", id))
                    defer span.End()
                    defer func() {
                Severity: Major
                Found in image/tarexport/load.go - About 35 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status