dotcloud/docker

View on GitHub
distribution/manifest.go

Summary

Maintainability
B
4 hrs
Test Coverage

Function detectManifestBlobMediaType has 12 return statements (exceeds 4 allowed).
Open

func detectManifestBlobMediaType(dt []byte) (string, error) {
    var mfst struct {
        MediaType string          `json:"mediaType"`
        Manifests json.RawMessage `json:"manifests"` // oci index, manifest list
        Config    json.RawMessage `json:"config"`    // schema2 Manifest
Severity: Major
Found in distribution/manifest.go - About 1 hr to fix

    Function detectManifestBlobMediaType has 51 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func detectManifestBlobMediaType(dt []byte) (string, error) {
        var mfst struct {
            MediaType string          `json:"mediaType"`
            Manifests json.RawMessage `json:"manifests"` // oci index, manifest list
            Config    json.RawMessage `json:"config"`    // schema2 Manifest
    Severity: Minor
    Found in distribution/manifest.go - About 1 hr to fix

      Method manifestStore.getLocal has 7 return statements (exceeds 4 allowed).
      Open

      func (m *manifestStore) getLocal(ctx context.Context, desc ocispec.Descriptor, ref reference.Named) (distribution.Manifest, error) {
          ra, err := m.local.ReaderAt(ctx, desc)
          if err != nil {
              return nil, errors.Wrap(err, "error getting content store reader")
          }
      Severity: Major
      Found in distribution/manifest.go - About 45 mins to fix

        Method manifestStore.Put has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        func (m *manifestStore) Put(ctx context.Context, manifest distribution.Manifest, desc ocispec.Descriptor, w content.Writer, ref reference.Named) error {
        Severity: Minor
        Found in distribution/manifest.go - About 35 mins to fix

          Function detectManifestBlobMediaType has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
          Open

          func detectManifestBlobMediaType(dt []byte) (string, error) {
              var mfst struct {
                  MediaType string          `json:"mediaType"`
                  Manifests json.RawMessage `json:"manifests"` // oci index, manifest list
                  Config    json.RawMessage `json:"config"`    // schema2 Manifest
          Severity: Minor
          Found in distribution/manifest.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