ARM-software/golang-utils

View on GitHub
utils/filesystem/zip.go

Summary

Maintainability
D
2 days
Test Coverage

Method VFS.unzip has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

func (fs *VFS) unzip(ctx context.Context, source string, destination string, limits ILimits, currentDepth int64) (fileList []string, fileOnDiskCount uint64, sizeOnDisk uint64, err error) {

    err = parallelisation.DetermineContextError(ctx)
    if err != nil {
        return
Severity: Minor
Found in utils/filesystem/zip.go - About 1 day 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 VFS.ZipWithContextAndLimitsAndExclusionPatterns has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

func (fs *VFS) ZipWithContextAndLimitsAndExclusionPatterns(ctx context.Context, source string, destination string, limits ILimits, exclusionPatterns ...string) (err error) {
    if limits == nil {
        err = fmt.Errorf("%w: missing file system limits", commonerrors.ErrUndefined)
        return
    }
Severity: Minor
Found in utils/filesystem/zip.go - About 4 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 VFS.unzip has 95 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (fs *VFS) unzip(ctx context.Context, source string, destination string, limits ILimits, currentDepth int64) (fileList []string, fileOnDiskCount uint64, sizeOnDisk uint64, err error) {

    err = parallelisation.DetermineContextError(ctx)
    if err != nil {
        return
Severity: Major
Found in utils/filesystem/zip.go - About 2 hrs to fix

    Method VFS.ZipWithContextAndLimitsAndExclusionPatterns has 78 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (fs *VFS) ZipWithContextAndLimitsAndExclusionPatterns(ctx context.Context, source string, destination string, limits ILimits, exclusionPatterns ...string) (err error) {
        if limits == nil {
            err = fmt.Errorf("%w: missing file system limits", commonerrors.ErrUndefined)
            return
        }
    Severity: Major
    Found in utils/filesystem/zip.go - About 2 hrs to fix

      Method VFS.unzipZippedFile has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      func (fs *VFS) unzipZippedFile(ctx context.Context, dest string, zippedFile *zip.File, limits ILimits, currentDepth int64) (fileSizeOnDisk int64, err error) {
          err = parallelisation.DetermineContextError(ctx)
          if err != nil {
              return
          }
      Severity: Minor
      Found in utils/filesystem/zip.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

      Function newZipReader has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      func newZipReader(fs FS, source string, limits ILimits, currentDepth int64) (zipReader *zip.Reader, file File, err error) {
          if fs == nil {
              err = fmt.Errorf("%w: missing file system", commonerrors.ErrUndefined)
              return
          }
      Severity: Minor
      Found in utils/filesystem/zip.go - About 55 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 VFS.IsZipWithContext has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      func (fs *VFS) IsZipWithContext(ctx context.Context, path string) (ok bool, err error) {
          if path == "" {
              err = fmt.Errorf("%w: missing path", commonerrors.ErrUndefined)
              return
          }
      Severity: Minor
      Found in utils/filesystem/zip.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

      There are no issues that match your filters.

      Category
      Status