docker/docker

View on GitHub

Showing 1,853 of 1,853 total issues

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

package daemon

import (
    "context"
    "testing"
Severity: Major
Found in testutil/daemon/config.go and 1 other location - About 1 day to fix
testutil/daemon/secret.go on lines 1..74

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 658.

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

package daemon

import (
    "context"
    "testing"
Severity: Major
Found in testutil/daemon/secret.go and 1 other location - About 1 day to fix
testutil/daemon/config.go on lines 1..72

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 658.

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

File default_linux.go has 824 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package seccomp // import "github.com/docker/docker/profiles/seccomp"

import (
    "github.com/opencontainers/runtime-spec/specs-go"
    "golang.org/x/sys/unix"
Severity: Major
Found in profiles/seccomp/default_linux.go - About 1 day to fix

    Method GossipMessage.Unmarshal has a Cognitive Complexity of 77 (exceeds 20 allowed). Consider refactoring.
    Open

    func (m *GossipMessage) Unmarshal(dAtA []byte) error {
        l := len(dAtA)
        iNdEx := 0
        for iNdEx < l {
            preIndex := iNdEx
    Severity: Minor
    Found in libnetwork/networkdb/networkdb.pb.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 TableEvent.Unmarshal has 266 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (m *TableEvent) Unmarshal(dAtA []byte) error {
        l := len(dAtA)
        iNdEx := 0
        for iNdEx < l {
            preIndex := iNdEx
    Severity: Major
    Found in libnetwork/networkdb/networkdb.pb.go - About 1 day to fix

      File controller.go has 812 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      /*
      Package libnetwork provides the basic functionality and extension points to
      create network namespaces and allocate interfaces for containers to use.
      
          networkType := "bridge"
      Severity: Major
      Found in libnetwork/controller.go - About 1 day to fix

        Method Daemon.initNetworkController has a Cognitive Complexity of 75 (exceeds 20 allowed). Consider refactoring.
        Open

        func (daemon *Daemon) initNetworkController(daemonCfg *config.Config, activeSandboxes map[string]interface{}) error {
            netOptions, err := daemon.networkOptions(daemonCfg, nil, nil)
            if err != nil {
                return err
            }
        Severity: Minor
        Found in daemon/daemon_windows.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 Copier.copySrc has a Cognitive Complexity of 75 (exceeds 20 allowed). Consider refactoring.
        Open

        func (c *Copier) copySrc(name string, src io.Reader) {
            defer c.copyJobs.Done()
        
            bufSize := defaultBufSize
            if sizedLogger, ok := c.dst.(SizedLogger); ok {
        Severity: Minor
        Found in daemon/logger/copier.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

        Function DirCopy has a Cognitive Complexity of 75 (exceeds 20 allowed). Consider refactoring.
        Open

        func DirCopy(srcDir, dstDir string, copyMode Mode, copyOpaqueXattrs bool) error {
            copyWithFileRange := true
            copyWithFileClone := true
        
            // This is a map of source file inodes to dst file paths
        Severity: Minor
        Found in daemon/graphdriver/copy/copy.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 ImageService.resolveAllReferences has a Cognitive Complexity of 73 (exceeds 20 allowed). Consider refactoring.
        Open

        func (i *ImageService) resolveAllReferences(ctx context.Context, refOrID string) (*containerdimages.Image, []containerdimages.Image, error) {
            parsed, err := reference.ParseAnyReference(refOrID)
            if err != nil {
                return nil, nil, errdefs.InvalidParameter(err)
            }
        Severity: Minor
        Found in daemon/containerd/image.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

        File agent.go has 782 lines of code (exceeds 500 allowed). Consider refactoring.
        Open

        package libnetwork
        
        //go:generate protoc -I=. -I=../vendor/ --gogofaster_out=import_path=github.com/docker/docker/libnetwork:. agent.proto
        
        import (
        Severity: Major
        Found in libnetwork/agent.go - About 1 day to fix

          Function check_network has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
          Open

          def check_network(nw_name, ingress=False):
          
              print "Verifying LB programming for containers on network %s" % nw_name
          
              data = cli.inspect_network(nw_name, verbose=True)
          Severity: Minor
          Found in libnetwork/cmd/ssd/ssd.py - 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

          Consider simplifying this complex logical expression.
          Open

              if resources.CPUShares != 0 ||
                  resources.Memory != 0 ||
                  resources.NanoCPUs != 0 ||
                  resources.CgroupParent != "" ||
                  resources.BlkioWeight != 0 ||
          Severity: Critical
          Found in container/container_windows.go - About 1 day to fix

            Function compare has a Cognitive Complexity of 70 (exceeds 20 allowed). Consider refactoring.
            Open

            func compare(a, b *container.Config) bool {
                if a == nil || b == nil {
                    return false
                }
            
            
            Severity: Minor
            Found in image/cache/compare.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

            File plugin.pb.go has 763 lines of code (exceeds 500 allowed). Consider refactoring.
            Open

            // Code generated by protoc-gen-gogo. DO NOT EDIT.
            // source: plugin.proto
            
            package runtime
            
            
            Severity: Major
            Found in api/types/swarm/runtime/plugin.pb.go - About 1 day to fix

              Method Builder.Build has a Cognitive Complexity of 67 (exceeds 20 allowed). Consider refactoring.
              Open

              func (b *Builder) Build(ctx context.Context, opt backend.BuildConfig) (*builder.Result, error) {
                  if len(opt.Options.Outputs) > 1 {
                      return nil, errors.Errorf("multiple outputs not supported")
                  }
              
              
              Severity: Minor
              Found in builder/builder-next/builder.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 ImageService.ImageDelete has a Cognitive Complexity of 66 (exceeds 20 allowed). Consider refactoring.
              Open

              func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force, prune bool) (response []imagetypes.DeleteResponse, retErr error) {
                  start := time.Now()
                  defer func() {
                      if retErr == nil {
                          dimages.ImageActions.WithValues("delete").UpdateSince(start)
              Severity: Minor
              Found in daemon/containerd/image_delete.go - About 7 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 client.createWindows has a Cognitive Complexity of 65 (exceeds 20 allowed). Consider refactoring.
              Open

              func (c *client) createWindows(id string, spec *specs.Spec, runtimeOptions interface{}) (*container, error) {
                  logger := c.logger.WithField("container", id)
                  configuration := &hcsshim.ContainerConfig{
                      SystemType:              "Container",
                      Name:                    id,
              Severity: Minor
              Found in libcontainerd/local/local_windows.go - About 7 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

              Function merge has a Cognitive Complexity of 64 (exceeds 20 allowed). Consider refactoring.
              Open

              func merge(userConf, imageConf *containertypes.Config) error {
                  if userConf.User == "" {
                      userConf.User = imageConf.User
                  }
                  if len(userConf.ExposedPorts) == 0 {
              Severity: Minor
              Found in daemon/commit.go - About 7 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 Endpoint.sbJoin has a Cognitive Complexity of 63 (exceeds 20 allowed). Consider refactoring.
              Open

              func (ep *Endpoint) sbJoin(sb *Sandbox, options ...EndpointOption) (err error) {
                  n, err := ep.getNetworkFromStore()
                  if err != nil {
                      return fmt.Errorf("failed to get network from store during join: %v", err)
                  }
              Severity: Minor
              Found in libnetwork/endpoint.go - About 7 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

              Severity
              Category
              Status
              Source
              Language