dotcloud/docker

View on GitHub

Showing 1,468 of 1,914 total issues

Avoid deeply nested control flow statements.
Open

                    if logErr := c.dst.Log(msg); logErr != nil {
                        logDriverError(c.dst.Name(), string(msg.Line), logErr)
                    }
Severity: Major
Found in daemon/logger/copier.go - About 45 mins to fix

    Method Daemon.containerStart has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    func (daemon *Daemon) containerStart(ctx context.Context, daemonCfg *configStore, container *container.Container, checkpoint string, checkpointDir string, resetRestartManager bool) (retErr error) {
    Severity: Minor
    Found in daemon/start.go - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if msg.PLogMetaData == nil {
                              msg.Timestamp = time.Now().UTC()
                          } else {
                              msg.Timestamp = partialTS
                          }
      Severity: Major
      Found in daemon/logger/copier.go - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if firstPartial {
                                msg.Timestamp = time.Now().UTC()
                                partialTS = msg.Timestamp
                                partialid = stringid.GenerateRandomID()
                                ordinal = 1
        Severity: Major
        Found in daemon/logger/copier.go - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if path[n] == '.' {
                                  break
                              }
          Severity: Major
          Found in daemon/logger/loggerutils/file_windows.go - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if hasMorePartial {
                                    msg.PLogMetaData = &types.PartialLogMetaData{ID: partialid, Ordinal: ordinal, Last: true}
            
                                    // reset
                                    partialid = ""
            Severity: Major
            Found in daemon/logger/copier.go - About 45 mins to fix

              Method Daemon.Kill has 7 return statements (exceeds 4 allowed).
              Open

              func (daemon *Daemon) Kill(container *containerpkg.Container) error {
                  if !container.IsRunning() {
                      return errNotRunning(container.ID)
                  }
              
              
              Severity: Major
              Found in daemon/kill.go - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if isLastManager(reachable, unreachable) {
                                        msg += "Removing the last manager erases all current state of the swarm. Use `--force` to ignore this message. "
                                        return errors.WithStack(notAvailableError(msg))
                                    }
                Severity: Major
                Found in daemon/cluster/swarm.go - About 45 mins to fix

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

                  func New(info logger.Info) (logger.Logger, error) {
                      tag, err := loggerutils.ParseLogTag(info, loggerutils.DefaultTemplate)
                      if err != nil {
                          return nil, err
                      }
                  Severity: Major
                  Found in daemon/logger/syslog/syslog.go - About 45 mins to fix

                    Function getService has 7 return statements (exceeds 4 allowed).
                    Open

                    func getService(ctx context.Context, c swarmapi.ControlClient, input string, insertDefaults bool) (*swarmapi.Service, error) {
                        // GetService to match via full ID.
                        if rg, err := c.GetService(ctx, &swarmapi.GetServiceRequest{ServiceID: input, InsertDefaults: insertDefaults}); err == nil {
                            return rg.Service, nil
                        }
                    Severity: Major
                    Found in daemon/cluster/helpers.go - About 45 mins to fix

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

                      func (r *reader) wait(ctx context.Context) (bool, error) {
                          deadline := r.drainDeadline
                          if d, ok := ctx.Deadline(); ok && d.Before(deadline) {
                              deadline = d
                          }
                      Severity: Major
                      Found in daemon/logger/journald/read.go - About 45 mins to fix

                        Method reader.drainJournal has 7 return statements (exceeds 4 allowed).
                        Open

                        func (r *reader) drainJournal(ctx context.Context) (bool, error) {
                            for i := 0; ; i++ {
                                // Read the entry's timestamp.
                                timestamp, err := r.j.Realtime()
                                if err != nil {
                        Severity: Major
                        Found in daemon/logger/journald/read.go - About 45 mins to fix

                          Function parseAddress has 7 return statements (exceeds 4 allowed).
                          Open

                          func parseAddress(address string) (string, string, error) {
                              if address == "" {
                                  return "", "", nil
                              }
                              addr, err := url.Parse(address)
                          Severity: Major
                          Found in daemon/logger/syslog/syslog.go - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                for ; n < l; n++ {
                                                    if os.IsPathSeparator(path[n]) {
                                                        break
                                                    }
                                                }
                            Severity: Major
                            Found in daemon/logger/loggerutils/file_windows.go - About 45 mins to fix

                              Function validateHealthCheck has 7 return statements (exceeds 4 allowed).
                              Open

                              func validateHealthCheck(healthConfig *containertypes.HealthConfig) error {
                                  if healthConfig == nil {
                                      return nil
                                  }
                                  if healthConfig.Interval != 0 && healthConfig.Interval < containertypes.MinimumDuration {
                              Severity: Major
                              Found in daemon/container.go - About 45 mins to fix

                                Method splunkLogger.postMessages has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                                Open

                                func (l *splunkLogger) postMessages(messages []*splunkMessage, lastChance bool) []*splunkMessage {
                                    messagesLen := len(messages)
                                
                                    ctx, cancel := context.WithTimeout(context.Background(), batchSendTimeout)
                                    defer cancel()
                                Severity: Minor
                                Found in daemon/logger/splunk/splunk.go - About 45 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

                                Avoid deeply nested control flow statements.
                                Open

                                                    if err != io.EOF {
                                                        logReadsFailedCount.Inc(1)
                                                        log.G(context.TODO()).Errorf("Error scanning log stream: %s", err)
                                                        return
                                                    }
                                Severity: Major
                                Found in daemon/logger/copier.go - About 45 mins to fix

                                  Function ValidateLogOpt has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                                  Open

                                  func ValidateLogOpt(cfg map[string]string) error {
                                      for key := range cfg {
                                          switch key {
                                          case logGroupKey:
                                          case logStreamKey:
                                  Severity: Minor
                                  Found in daemon/logger/awslogs/cloudwatchlogs.go - About 45 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 newStreamConfig has 7 return statements (exceeds 4 allowed).
                                  Open

                                  func newStreamConfig(info logger.Info) (*logStreamConfig, error) {
                                      logGroupName := info.Config[logGroupKey]
                                      logStreamName, err := loggerutils.ParseLogTag(info, "{{.FullID}}")
                                      if err != nil {
                                          return nil, err
                                  Severity: Major
                                  Found in daemon/logger/awslogs/cloudwatchlogs.go - About 45 mins to fix

                                    Function parseAddress has 7 return statements (exceeds 4 allowed).
                                    Open

                                    func parseAddress(address string) (*location, error) {
                                        if address == "" {
                                            return &location{
                                                protocol: defaultProtocol,
                                                host:     defaultHost,
                                    Severity: Major
                                    Found in daemon/logger/fluentd/fluentd.go - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language