docker/docker

View on GitHub

Showing 1,853 of 1,853 total issues

Function ServiceSpecToGRPC has a Cognitive Complexity of 58 (exceeds 20 allowed). Consider refactoring.
Open

func ServiceSpecToGRPC(s types.ServiceSpec) (swarmapi.ServiceSpec, error) {
    name := s.Name
    if name == "" {
        name = namesgenerator.GetRandomName(0)
    }
Severity: Minor
Found in daemon/cluster/convert/service.go - About 6 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

File container_routes.go has 690 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package container // import "github.com/docker/docker/api/server/router/container"

import (
    "context"
    "encoding/json"
Severity: Minor
Found in api/server/router/container/container_routes.go - About 6 hrs to fix

    Method LogEntry.Unmarshal has 188 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (m *LogEntry) Unmarshal(dAtA []byte) error {
        l := len(dAtA)
        iNdEx := 0
        for iNdEx < l {
            preIndex := iNdEx
    Severity: Major
    Found in api/types/plugins/logdriver/entry.pb.go - About 6 hrs to fix

      Method Builder.Build has 186 lines of code (exceeds 50 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: Major
      Found in builder/builder-next/builder.go - About 6 hrs to fix

        Method pushDescriptor.Upload has a Cognitive Complexity of 57 (exceeds 20 allowed). Consider refactoring.
        Open

        func (pd *pushDescriptor) Upload(ctx context.Context, progressOutput progress.Output) (distribution.Descriptor, error) {
            // Skip foreign layers unless this registry allows nondistributable artifacts.
            if !pd.endpoint.AllowNondistributableArtifacts {
                if fs, ok := pd.layer.(distribution.Describable); ok {
                    if d := fs.Descriptor(); len(d.URLs) > 0 {
        Severity: Minor
        Found in distribution/push_v2.go - About 6 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 BulkSyncMessage.Unmarshal has 184 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

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

          File networkallocator.go has 678 lines of code (exceeds 500 allowed). Consider refactoring.
          Open

          package cnmallocator
          
          import (
              "context"
              "fmt"
          Severity: Minor
          Found in libnetwork/cnmallocator/networkallocator.go - About 6 hrs to fix

            Method Cluster.ServiceLogs has a Cognitive Complexity of 56 (exceeds 20 allowed). Consider refactoring.
            Open

            func (c *Cluster) ServiceLogs(ctx context.Context, selector *backend.LogSelector, config *container.LogsOptions) (<-chan *backend.LogMessage, error) {
                c.mu.RLock()
                defer c.mu.RUnlock()
            
                state := c.currentNodeState()
            Severity: Minor
            Found in daemon/cluster/services.go - About 6 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 Daemon.ContainerRename has a Cognitive Complexity of 56 (exceeds 20 allowed). Consider refactoring.
            Open

            func (daemon *Daemon) ContainerRename(oldName, newName string) (retErr error) {
                if oldName == "" || newName == "" {
                    return errdefs.InvalidParameter(errors.New("Neither old nor new names may be empty"))
                }
            
            
            Severity: Minor
            Found in daemon/rename.go - About 6 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

            File backend_linux.go has 676 lines of code (exceeds 500 allowed). Consider refactoring.
            Open

            package plugin // import "github.com/docker/docker/plugin"
            
            import (
                "archive/tar"
                "bytes"
            Severity: Minor
            Found in plugin/backend_linux.go - About 6 hrs to fix

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

              func (r *containerRouter) initRoutes() {
                  r.routes = []router.Route{
                      // HEAD
                      router.NewHeadRoute("/containers/{name:.*}/archive", r.headContainersArchive),
                      // GET
              Severity: Major
              Found in api/server/router/container/container.go and 1 other location - About 6 hrs to fix
              api/server/router/swarm/cluster.go on lines 25..63

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

              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 (sr *swarmRouter) initRoutes() {
                  sr.routes = []router.Route{
                      router.NewPostRoute("/swarm/init", sr.initCluster),
                      router.NewPostRoute("/swarm/join", sr.joinCluster),
                      router.NewPostRoute("/swarm/leave", sr.leaveCluster),
              Severity: Major
              Found in api/server/router/swarm/cluster.go and 1 other location - About 6 hrs to fix
              api/server/router/container/container.go on lines 33..71

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

              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 Cluster.resolveSystemAddrViaSubnetCheck has a Cognitive Complexity of 55 (exceeds 20 allowed). Consider refactoring.
              Open

              func (c *Cluster) resolveSystemAddrViaSubnetCheck() (net.IP, error) {
                  // Use the system's only IP address, or fail if there are
                  // multiple addresses to choose from. Skip interfaces which
                  // are managed by docker via subnet check.
                  interfaces, err := net.Interfaces()
              Severity: Minor
              Found in daemon/cluster/listen_addr.go - About 6 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 Daemon.buildSandboxOptions has a Cognitive Complexity of 55 (exceeds 20 allowed). Consider refactoring.
              Open

              func (daemon *Daemon) buildSandboxOptions(cfg *config.Config, container *container.Container) ([]libnetwork.SandboxOption, error) {
                  var sboxOptions []libnetwork.SandboxOption
                  sboxOptions = append(sboxOptions, libnetwork.OptionHostname(container.Config.Hostname), libnetwork.OptionDomainname(container.Config.Domainname))
              
                  if container.HostConfig.NetworkMode.IsHost() {
              Severity: Minor
              Found in daemon/container_operations.go - About 6 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 ServiceSpecToGRPC has 175 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func ServiceSpecToGRPC(s types.ServiceSpec) (swarmapi.ServiceSpec, error) {
                  name := s.Name
                  if name == "" {
                      name = namesgenerator.GetRandomName(0)
                  }
              Severity: Major
              Found in daemon/cluster/convert/service.go - About 6 hrs to fix

                Method Reader.TestFollow has 173 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (tr Reader) TestFollow(t *testing.T) {
                    // Reader sends all logs and closes after logger is closed
                    // - Starting from empty log (like run)
                    for i, tail := range []int{-1, 0, 1, 42} {
                        i, tail := i, tail
                Severity: Major
                Found in daemon/logger/loggertest/logreader.go - About 5 hrs to fix

                  Method puller.pullSchema2Layers has a Cognitive Complexity of 54 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (p *puller) pullSchema2Layers(ctx context.Context, target distribution.Descriptor, layers []distribution.Descriptor, platform *ocispec.Platform) (id digest.Digest, err error) {
                      if _, err := p.config.ImageStore.Get(ctx, target.Digest); err == nil {
                          // If the image already exists locally, no need to pull
                          // anything.
                          return target.Digest, nil
                  Severity: Minor
                  Found in distribution/pull_v2.go - About 5 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 skipAgent has a Cognitive Complexity of 54 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func skipAgent(dAtA []byte) (n int, err error) {
                      l := len(dAtA)
                      iNdEx := 0
                      depth := 0
                      for iNdEx < l {
                  Severity: Minor
                  Found in libnetwork/agent.pb.go - About 5 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 skipNetworkdb has a Cognitive Complexity of 54 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func skipNetworkdb(dAtA []byte) (n int, err error) {
                      l := len(dAtA)
                      iNdEx := 0
                      depth := 0
                      for iNdEx < l {
                  Severity: Minor
                  Found in libnetwork/networkdb/networkdb.pb.go - About 5 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 skipOverlay has a Cognitive Complexity of 54 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func skipOverlay(dAtA []byte) (n int, err error) {
                      l := len(dAtA)
                      iNdEx := 0
                      depth := 0
                      for iNdEx < l {
                  Severity: Minor
                  Found in libnetwork/drivers/overlay/overlay.pb.go - About 5 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