dotcloud/docker

View on GitHub

Showing 1,904 of 1,904 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    if !parentExists(config.Parent) {
        // Create a dummy link if a dummy name is set for parent
        if dummyName := getDummyName(config.ID); dummyName == config.Parent {
            err := createDummyLink(config.Parent, dummyName)
            if err != nil {
Severity: Major
Found in libnetwork/drivers/macvlan/macvlan_network.go and 1 other location - About 1 hr to fix
libnetwork/drivers/ipvlan/ipvlan_network.go on lines 89..111

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 137.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func (n NetworkMode) NetworkName() string {
    switch {
    case n.IsDefault():
        return network.NetworkDefault
    case n.IsBridge():
Severity: Major
Found in api/types/container/hostconfig_unix.go and 1 other location - About 1 hr to fix
api/types/container/hostconfig_windows.go on lines 28..47

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 137.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func (n NetworkMode) NetworkName() string {
    switch {
    case n.IsDefault():
        return network.NetworkDefault
    case n.IsBridge():
Severity: Major
Found in api/types/container/hostconfig_windows.go and 1 other location - About 1 hr to fix
api/types/container/hostconfig_unix.go on lines 28..45

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 137.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method Manager.Push has 11 return statements (exceeds 4 allowed).
Open

func (pm *Manager) Push(ctx context.Context, name string, metaHeader http.Header, authConfig *registry.AuthConfig, outStream io.Writer) error {
    p, err := pm.config.Store.GetV2Plugin(name)
    if err != nil {
        return err
    }
Severity: Major
Found in plugin/backend_linux.go - About 1 hr to fix

    Method ImageCache.GetCache has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
    Open

    func (ic *ImageCache) GetCache(parentID string, cfg *containertypes.Config, platform ocispec.Platform) (string, error) {
        imgID, err := ic.localImageCache.GetCache(parentID, cfg, platform)
        if err != nil {
            return "", err
        }
    Severity: Minor
    Found in image/cache/cache.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 SwitchRoot has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
    Open

    func SwitchRoot(path string) error {
        if mounted, _ := mountinfo.Mounted(path); !mounted {
            if err := mount.Mount(path, path, "bind", "rbind,rw"); err != nil {
                return realChroot(path)
            }
    Severity: Minor
    Found in internal/mounttree/switchroot_linux.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 Push has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
    Open

    func Push(ctx context.Context, ref reference.Named, config *ImagePushConfig) error {
        // FIXME: Allow to interrupt current push when new push of same image is done.
    
        // Resolve the Repository name from fqn to RepositoryInfo
        repoInfo, err := config.RegistryService.ResolveRepository(ref)
    Severity: Minor
    Found in distribution/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 Sandbox.delete has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
    Open

    func (sb *Sandbox) delete(ctx context.Context, force bool) error {
        sb.mu.Lock()
        if sb.inDelete {
            sb.mu.Unlock()
            return types.ForbiddenErrorf("another sandbox delete in progress")
    Severity: Minor
    Found in libnetwork/sandbox.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 Allocator.RequestPool has 11 return statements (exceeds 4 allowed).
    Open

    func (a *Allocator) RequestPool(req ipamapi.PoolRequest) (ipamapi.AllocatedPool, error) {
        log.G(context.TODO()).Debugf("RequestPool: %+v", req)
    
        parseErr := func(err error) error {
            return types.InternalErrorf("failed to parse pool request for address space %q pool %q subpool %q: %v", req.AddressSpace, req.Pool, req.SubPool, err)
    Severity: Major
    Found in libnetwork/ipams/defaultipam/allocator.go - About 1 hr to fix

      Function skipAgent has 11 return statements (exceeds 4 allowed).
      Open

      func skipAgent(dAtA []byte) (n int, err error) {
          l := len(dAtA)
          iNdEx := 0
          depth := 0
          for iNdEx < l {
      Severity: Major
      Found in libnetwork/agent.pb.go - About 1 hr to fix

        Function skipOverlay has 11 return statements (exceeds 4 allowed).
        Open

        func skipOverlay(dAtA []byte) (n int, err error) {
            l := len(dAtA)
            iNdEx := 0
            depth := 0
            for iNdEx < l {
        Severity: Major
        Found in libnetwork/drivers/overlay/overlay.pb.go - About 1 hr to fix

          Method bridgeNetwork.addPortMappings has 11 return statements (exceeds 4 allowed).
          Open

          func (n *bridgeNetwork) addPortMappings(
              epAddrV4, epAddrV6 *net.IPNet,
              cfg []types.PortBinding,
              defHostIP net.IP,
          ) (_ []portBinding, retErr error) {
          Severity: Major
          Found in libnetwork/drivers/bridge/port_mapping_linux.go - About 1 hr to fix

            Method driver.deleteNetwork has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
            Open

            func (d *driver) deleteNetwork(nid string) error {
                var err error
            
                // Get network handler and remove it from driver
                d.Lock()
            Severity: Minor
            Found in libnetwork/drivers/bridge/bridge_linux.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 driver.link has 11 return statements (exceeds 4 allowed).
            Open

            func (d *driver) link(network *bridgeNetwork, endpoint *bridgeEndpoint, enable bool) (retErr error) {
                cc := endpoint.containerConfig
                ec := endpoint.extConnConfig
                if cc == nil || ec == nil || (len(cc.ParentEndpoints) == 0 && len(cc.ChildEndpoints) == 0) {
                    // nothing to do
            Severity: Major
            Found in libnetwork/drivers/bridge/bridge_linux.go - About 1 hr to fix

              Function skipNetworkdb has 11 return statements (exceeds 4 allowed).
              Open

              func skipNetworkdb(dAtA []byte) (n int, err error) {
                  l := len(dAtA)
                  iNdEx := 0
                  depth := 0
                  for iNdEx < l {
              Severity: Major
              Found in libnetwork/networkdb/networkdb.pb.go - About 1 hr to fix

                Method driver.DeleteNetwork has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
                Open

                func (d *driver) DeleteNetwork(nid string) error {
                    n := d.network(nid)
                    if n == nil {
                        return fmt.Errorf("network id %s not found", nid)
                    }
                Severity: Minor
                Found in libnetwork/drivers/ipvlan/ipvlan_network.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 cnmNetworkAllocator.allocatePools has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
                Open

                func (na *cnmNetworkAllocator) allocatePools(n *api.Network) (map[string]string, error) {
                    ipam, dName, dOptions, err := na.resolveIPAM(n)
                    if err != nil {
                        return nil, err
                    }
                Severity: Minor
                Found in libnetwork/cnmallocator/networkallocator.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 cnmNetworkAllocator.allocateNetworkIPs has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
                Open

                func (na *cnmNetworkAllocator) allocateNetworkIPs(nAttach *api.NetworkAttachment) error {
                    var ip *net.IPNet
                    var opts map[string]string
                
                    ipam, _, _, err := na.resolveIPAM(nAttach.Network)
                Severity: Minor
                Found in libnetwork/cnmallocator/networkallocator.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 Service.Search has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
                Open

                func (s *Service) Search(ctx context.Context, searchFilters filters.Args, term string, limit int, authConfig *registry.AuthConfig, headers map[string][]string) ([]registry.SearchResult, error) {
                    if err := searchFilters.Validate(acceptedSearchFilterTags); err != nil {
                        return nil, err
                    }
                
                
                Severity: Minor
                Found in registry/search.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 skipPlugin has 11 return statements (exceeds 4 allowed).
                Open

                func skipPlugin(dAtA []byte) (n int, err error) {
                    l := len(dAtA)
                    iNdEx := 0
                    depth := 0
                    for iNdEx < l {
                Severity: Major
                Found in api/types/swarm/runtime/plugin.pb.go - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language