docker/docker

View on GitHub

Showing 1,412 of 1,855 total issues

Function getTask has 5 return statements (exceeds 4 allowed).
Open

func getTask(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Task, error) {
    // GetTask to match via full ID.
    if rg, err := c.GetTask(ctx, &swarmapi.GetTaskRequest{TaskID: input}); err == nil {
        return rg.Task, nil
    }
Severity: Major
Found in daemon/cluster/helpers.go - About 35 mins to fix

    Function getNetwork has 5 return statements (exceeds 4 allowed).
    Open

    func getNetwork(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Network, error) {
        // GetNetwork to match via full ID.
        if rg, err := c.GetNetwork(ctx, &swarmapi.GetNetworkRequest{NetworkID: input}); err == nil {
            return rg.Network, nil
        }
    Severity: Major
    Found in daemon/cluster/helpers.go - About 35 mins to fix

      Function getVolume has 5 return statements (exceeds 4 allowed).
      Open

      func getVolume(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Volume, error) {
          // GetVolume to match via full ID
          if v, err := c.GetVolume(ctx, &swarmapi.GetVolumeRequest{VolumeID: input}); err == nil {
              return v.Volume, nil
          }
      Severity: Major
      Found in daemon/cluster/helpers.go - About 35 mins to fix

        Function waitUntilFlushedImpl has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
        Open

        func waitUntilFlushedImpl(s *journald) error {
            if s.readSyncTimeout == 0 {
                return nil
            }
        
        
        Severity: Minor
        Found in daemon/logger/journald/read.go - About 35 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

        Function verifySplunkConnection has 5 return statements (exceeds 4 allowed).
        Open

        func verifySplunkConnection(l *splunkLogger) error {
            req, err := http.NewRequest(http.MethodOptions, l.url, nil)
            if err != nil {
                return err
            }
        Severity: Major
        Found in daemon/logger/splunk/splunk.go - About 35 mins to fix

          Method reader.wait has 5 return statements (exceeds 4 allowed).
          Open

          func (r *reader) wait() (bool, error) {
              for {
                  dur := waitInterval
                  if !r.drainDeadline.IsZero() {
                      dur = time.Until(r.drainDeadline)
          Severity: Major
          Found in daemon/logger/journald/read.go - About 35 mins to fix

            Method Controller.Wait has 5 return statements (exceeds 4 allowed).
            Open

            func (p *Controller) Wait(ctx context.Context) error {
                p.logger.Debug("Wait")
            
                pl, err := p.backend.Get(p.pluginID)
                if err != nil {
            Severity: Major
            Found in daemon/cluster/controllers/plugin/controller.go - About 35 mins to fix

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

              func (c *Cluster) Info(ctx context.Context) types.Info {
                  info := types.Info{
                      NodeAddr: c.GetAdvertiseAddress(),
                  }
                  c.mu.RLock()
              Severity: Minor
              Found in daemon/cluster/swarm.go - About 35 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

              Function getConfig has 5 return statements (exceeds 4 allowed).
              Open

              func getConfig(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Config, error) {
                  // attempt to lookup config by full ID
                  if rg, err := c.GetConfig(ctx, &swarmapi.GetConfigRequest{ConfigID: input}); err == nil {
                      return rg.Config, nil
                  }
              Severity: Major
              Found in daemon/cluster/helpers.go - About 35 mins to fix

                Method pluginAdapterWithRead.ReadLogs has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                Open

                func (a *pluginAdapterWithRead) ReadLogs(config ReadConfig) *LogWatcher {
                    watcher := NewLogWatcher()
                
                    go func() {
                        defer close(watcher.Msg)
                Severity: Minor
                Found in daemon/logger/adapter.go - About 35 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 follow.Do has 5 return statements (exceeds 4 allowed).
                Open

                func (fl *follow) Do(f *os.File, read logPos) {
                    fl.log = log.G(context.TODO()).WithFields(log.Fields{
                        "module": "logger",
                        "file":   f.Name(),
                    })
                Severity: Major
                Found in daemon/logger/loggerutils/follow.go - About 35 mins to fix

                  Function makePluginAdapter has 5 return statements (exceeds 4 allowed).
                  Open

                  func makePluginAdapter(p plugingetter.CompatPlugin) (metricsPlugin, error) {
                      if pc, ok := p.(plugingetter.PluginWithV1Client); ok {
                          return &metricsPluginAdapter{pc.Client(), p.Name()}, nil
                      }
                  
                  
                  Severity: Major
                  Found in daemon/metrics.go - About 35 mins to fix

                    Method Daemon.NetworksPrune has 5 return statements (exceeds 4 allowed).
                    Open

                    func (daemon *Daemon) NetworksPrune(ctx context.Context, pruneFilters filters.Args) (*types.NetworksPruneReport, error) {
                        if !atomic.CompareAndSwapInt32(&daemon.pruneRunning, 0, 1) {
                            return nil, errPruneRunning
                        }
                        defer atomic.StoreInt32(&daemon.pruneRunning, 0)
                    Severity: Major
                    Found in daemon/prune.go - About 35 mins to fix

                      Method Copier.copySrc has 5 return statements (exceeds 4 allowed).
                      Open

                      func (c *Copier) copySrc(name string, src io.Reader) {
                          defer c.copyJobs.Done()
                      
                          bufSize := defaultBufSize
                          if sizedLogger, ok := c.dst.(SizedLogger); ok {
                      Severity: Major
                      Found in daemon/logger/copier.go - About 35 mins to fix

                        Method Daemon.deleteNetwork has 5 return statements (exceeds 4 allowed).
                        Open

                        func (daemon *Daemon) deleteNetwork(nw *libnetwork.Network, dynamic bool) error {
                            if runconfig.IsPreDefinedNetwork(nw.Name()) && !dynamic {
                                err := fmt.Errorf("%s is a pre-defined network and cannot be removed", nw.Name())
                                return errdefs.Forbidden(err)
                            }
                        Severity: Major
                        Found in daemon/network.go - About 35 mins to fix

                          Function getSystemCPUUsage has 5 return statements (exceeds 4 allowed).
                          Open

                          func getSystemCPUUsage() (cpuUsage uint64, cpuNum uint32, err error) {
                              f, err := os.Open("/proc/stat")
                              if err != nil {
                                  return 0, 0, err
                              }
                          Severity: Major
                          Found in daemon/stats_unix.go - About 35 mins to fix

                            Method Daemon.createSpecWindowsFields has 5 return statements (exceeds 4 allowed).
                            Open

                            func (daemon *Daemon) createSpecWindowsFields(c *container.Container, s *specs.Spec, isHyperV bool) error {
                                s.Hostname = c.FullHostname()
                            
                                if len(s.Process.Cwd) == 0 {
                                    // We default to C:\ to workaround the oddity of the case that the
                            Severity: Major
                            Found in daemon/oci_windows.go - About 35 mins to fix

                              Method Daemon.getActiveContainer has 5 return statements (exceeds 4 allowed).
                              Open

                              func (daemon *Daemon) getActiveContainer(name string) (*container.Container, error) {
                                  ctr, err := daemon.GetContainer(name)
                                  if err != nil {
                                      return nil, err
                                  }
                              Severity: Major
                              Found in daemon/exec.go - About 35 mins to fix

                                Function New has 5 return statements (exceeds 4 allowed).
                                Open

                                func New(info logger.Info) (logger.Logger, error) {
                                    fluentConfig, err := parseConfig(info.Config)
                                    if err != nil {
                                        return nil, errdefs.InvalidParameter(err)
                                    }
                                Severity: Major
                                Found in daemon/logger/fluentd/fluentd.go - About 35 mins to fix

                                  Method Daemon.containerRm has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func (daemon *Daemon) containerRm(cfg *config.Config, name string, opts *backend.ContainerRmConfig) error {
                                      start := time.Now()
                                      ctr, err := daemon.GetContainer(name)
                                      if err != nil {
                                          return err
                                  Severity: Major
                                  Found in daemon/delete.go - About 35 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language