dotcloud/docker

View on GitHub
layer/layer_store.go

Summary

Maintainability
D
2 days
Test Coverage

File layer_store.go has 630 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package layer // import "github.com/docker/docker/layer"

import (
    "context"
    "errors"
Severity: Minor
Found in layer/layer_store.go - About 5 hrs to fix

    layerStore has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type layerStore struct {
        store       *fileMetadataStore
        driver      graphdriver.Driver
        useTarSplit bool
    
    
    Severity: Minor
    Found in layer/layer_store.go - About 2 hrs to fix

      Method layerStore.registerWithDescriptor has 71 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (ls *layerStore) registerWithDescriptor(ts io.Reader, parent ChainID, descriptor distribution.Descriptor) (Layer, error) {
          // cErr is used to hold the error which will always trigger
          // cleanup of creates sources but may not be an error returned
          // to the caller (already exists).
          var cErr error
      Severity: Minor
      Found in layer/layer_store.go - About 1 hr to fix

        Method layerStore.CreateRWLayer has 60 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (ls *layerStore) CreateRWLayer(name string, parent ChainID, opts *CreateRWLayerOpts) (_ RWLayer, err error) {
            var (
                storageOpt map[string]string
                initFunc   MountInit
                mountLabel string
        Severity: Minor
        Found in layer/layer_store.go - About 1 hr to fix

          Method layerStore.registerWithDescriptor has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
          Open

          func (ls *layerStore) registerWithDescriptor(ts io.Reader, parent ChainID, descriptor distribution.Descriptor) (Layer, error) {
              // cErr is used to hold the error which will always trigger
              // cleanup of creates sources but may not be an error returned
              // to the caller (already exists).
              var cErr error
          Severity: Minor
          Found in layer/layer_store.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 layerStore.registerWithDescriptor has 9 return statements (exceeds 4 allowed).
          Open

          func (ls *layerStore) registerWithDescriptor(ts io.Reader, parent ChainID, descriptor distribution.Descriptor) (Layer, error) {
              // cErr is used to hold the error which will always trigger
              // cleanup of creates sources but may not be an error returned
              // to the caller (already exists).
              var cErr error
          Severity: Major
          Found in layer/layer_store.go - About 55 mins to fix

            Method layerStore.loadLayer has 8 return statements (exceeds 4 allowed).
            Open

            func (ls *layerStore) loadLayer(layer ChainID) (*roLayer, error) {
                cl, ok := ls.layerMap[layer]
                if ok {
                    return cl, nil
                }
            Severity: Major
            Found in layer/layer_store.go - About 50 mins to fix

              Method layerStore.ReleaseRWLayer has 8 return statements (exceeds 4 allowed).
              Open

              func (ls *layerStore) ReleaseRWLayer(l RWLayer) ([]Metadata, error) {
                  name := l.Name()
                  ls.locker.Lock(name)
                  defer ls.locker.Unlock(name)
              
              
              Severity: Major
              Found in layer/layer_store.go - About 50 mins to fix

                Method layerStore.loadMount has 6 return statements (exceeds 4 allowed).
                Open

                func (ls *layerStore) loadMount(mount string) error {
                    ls.mountL.Lock()
                    defer ls.mountL.Unlock()
                    if _, ok := ls.mounts[mount]; ok {
                        return nil
                Severity: Major
                Found in layer/layer_store.go - About 40 mins to fix

                  Method layerStore.CreateRWLayer has 6 return statements (exceeds 4 allowed).
                  Open

                  func (ls *layerStore) CreateRWLayer(name string, parent ChainID, opts *CreateRWLayerOpts) (_ RWLayer, err error) {
                      var (
                          storageOpt map[string]string
                          initFunc   MountInit
                          mountLabel string
                  Severity: Major
                  Found in layer/layer_store.go - About 40 mins to fix

                    Method layerStore.initMount has 5 return statements (exceeds 4 allowed).
                    Open

                    func (ls *layerStore) initMount(graphID, parent, mountLabel string, initFunc MountInit, storageOpt map[string]string) (string, error) {
                        // Use "<graph-id>-init" to maintain compatibility with graph drivers
                        // which are expecting this layer with this special name. If all
                        // graph drivers can be updated to not rely on knowing about this layer
                        // then the initID should be randomly generated.
                    Severity: Major
                    Found in layer/layer_store.go - About 35 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status