dotcloud/docker

View on GitHub

Showing 1,904 of 1,904 total issues

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

func (c *client) processEventStream(ctx context.Context, ns string) {
    // Create a new context specifically for this subscription.
    // The context must be cancelled to cancel the subscription.
    // In cases where we have to restart event stream processing,
    //   we'll need the original context b/c this one will be cancelled
Severity: Minor
Found in libcontainerd/remote/client.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 skipEntry has 11 return statements (exceeds 4 allowed).
Open

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

    Method ImageService.LoadImage has 11 return statements (exceeds 4 allowed).
    Open

    func (i *ImageService) LoadImage(ctx context.Context, inTar io.ReadCloser, platform *ocispec.Platform, outStream io.Writer, quiet bool) error {
        decompressed, err := dockerarchive.DecompressStream(inTar)
        if err != nil {
            return errors.Wrap(err, "failed to decompress input tar archive")
        }
    Severity: Major
    Found in daemon/containerd/image_exporter.go - About 1 hr to fix

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

      func (c *Cluster) GetServices(options types.ServiceListOptions) ([]swarm.Service, error) {
          c.mu.RLock()
          defer c.mu.RUnlock()
      
          state := c.currentNodeState()
      Severity: Minor
      Found in daemon/cluster/services.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 pluginAdapterWithRead.ReadLogs has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
      Open

      func (a *pluginAdapterWithRead) ReadLogs(ctx context.Context, config ReadConfig) *LogWatcher {
          watcher := NewLogWatcher()
      
          go func() {
              defer close(watcher.Msg)
      Severity: Minor
      Found in daemon/logger/adapter.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 follow.Do has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
      Open

      func (fl *follow) Do(ctx context.Context, f *os.File, read logPos) {
          fl.log = log.G(ctx).WithFields(log.Fields{
              "module": "logger",
              "file":   f.Name(),
          })
      Severity: Minor
      Found in daemon/logger/loggerutils/follow.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 splunkLogger.tryPostMessages has 11 return statements (exceeds 4 allowed).
      Open

      func (l *splunkLogger) tryPostMessages(ctx context.Context, messages []*splunkMessage) error {
          if len(messages) == 0 {
              return nil
          }
          var buffer bytes.Buffer
      Severity: Major
      Found in daemon/logger/splunk/splunk.go - About 1 hr to fix

        Function ServiceSpecToGRPC has 11 return statements (exceeds 4 allowed).
        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 1 hr to fix

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

          func (daemon *Daemon) ContainerStats(ctx context.Context, prefixOrName string, config *backend.ContainerStatsConfig) error {
              ctr, err := daemon.GetContainer(prefixOrName)
              if err != nil {
                  return err
              }
          Severity: Minor
          Found in daemon/stats.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 ImageService.GetImage has 11 return statements (exceeds 4 allowed).
          Open

          func (i *ImageService) GetImage(ctx context.Context, refOrID string, options backend.GetImageOpts) (retImg *image.Image, retErr error) {
              defer func() {
                  if retErr != nil || retImg == nil || options.Platform == nil {
                      return
                  }
          Severity: Major
          Found in daemon/images/image.go - About 1 hr to fix

            Method ImageService.ImageDelete has 11 return statements (exceeds 4 allowed).
            Open

            func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]imagetypes.DeleteResponse, error) {
                start := time.Now()
                records := []imagetypes.DeleteResponse{}
            
                img, err := i.GetImage(ctx, imageRef, backend.GetImageOpts{})
            Severity: Major
            Found in daemon/images/image_delete.go - About 1 hr to fix

              Function setResourcesInSpec has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
              Open

              func setResourcesInSpec(c *container.Container, s *specs.Spec, isHyperV bool) {
                  // In s.Windows.Resources
                  cpuShares := uint16(c.HostConfig.CPUShares)
                  cpuMaximum := uint16(c.HostConfig.CPUPercent) * 100
                  cpuCount := uint64(c.HostConfig.CPUCount)
              Severity: Minor
              Found in daemon/oci_windows.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 FrozenImagesLinux has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
              Open

              func FrozenImagesLinux(ctx context.Context, client client.APIClient, images ...string) error {
                  ctx, span := otel.Tracer("").Start(ctx, "LoadFrozenImages")
                  defer span.End()
              
                  var loadImages []struct{ srcName, destName string }
              Severity: Minor
              Found in testutil/fixtures/load/frozen.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

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

              func (sr *swarmRouter) getServiceLogs(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
                  if err := httputils.ParseForm(r); err != nil {
                      return err
                  }
              
              
              Severity: Major
              Found in api/server/router/swarm/cluster_routes.go and 1 other location - About 1 hr to fix
              api/server/router/swarm/cluster_routes.go on lines 292..302

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

              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

                      for key in realmark.keys():
                          if key not in stasks:
                              print "LB Index %s" % key, "present in IPVS but missing in docker daemon"
                              del realmark[key]
              Severity: Major
              Found in libnetwork/cmd/ssd/ssd.py and 1 other location - About 1 hr to fix
              libnetwork/cmd/ssd/ssd.py on lines 115..118

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

              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

                      for key in stasks.keys():
                          if key not in realmark:
                              print "LB Index %s" % key, "present in docker daemon but missing in IPVS"
                              del stasks[key]
              Severity: Major
              Found in libnetwork/cmd/ssd/ssd.py and 1 other location - About 1 hr to fix
              libnetwork/cmd/ssd/ssd.py on lines 110..113

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

              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 getentUser(name string) (user.User, error) {
                  reader, err := callGetent("passwd", name)
                  if err != nil {
                      return user.User{}, err
                  }
              Severity: Major
              Found in pkg/idtools/idtools_unix.go and 1 other location - About 1 hr to fix
              pkg/idtools/idtools_unix.go on lines 142..155

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

              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) getTaskLogs(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
                  if err := httputils.ParseForm(r); err != nil {
                      return err
                  }
              
              
              Severity: Major
              Found in api/server/router/swarm/cluster_routes.go and 1 other location - About 1 hr to fix
              api/server/router/swarm/cluster_routes.go on lines 304..314

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

              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 getentGroup(name string) (user.Group, error) {
                  reader, err := callGetent("group", name)
                  if err != nil {
                      return user.Group{}, err
                  }
              Severity: Major
              Found in pkg/idtools/idtools_unix.go and 1 other location - About 1 hr to fix
              pkg/idtools/idtools_unix.go on lines 103..116

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

              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 networkConfiguration.UnmarshalJSON has 52 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (ncfg *networkConfiguration) UnmarshalJSON(b []byte) error {
                  var (
                      err  error
                      nMap map[string]interface{}
                  )
              Severity: Minor
              Found in libnetwork/drivers/bridge/bridge_store.go - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language