Showing 1,468 of 1,914 total issues
Avoid deeply nested control flow statements. Open
Open
if logErr := c.dst.Log(msg); logErr != nil {
logDriverError(c.dst.Name(), string(msg.Line), logErr)
}
Method Daemon.containerStart
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (daemon *Daemon) containerStart(ctx context.Context, daemonCfg *configStore, container *container.Container, checkpoint string, checkpointDir string, resetRestartManager bool) (retErr error) {
Avoid deeply nested control flow statements. Open
Open
if msg.PLogMetaData == nil {
msg.Timestamp = time.Now().UTC()
} else {
msg.Timestamp = partialTS
}
Avoid deeply nested control flow statements. Open
Open
if firstPartial {
msg.Timestamp = time.Now().UTC()
partialTS = msg.Timestamp
partialid = stringid.GenerateRandomID()
ordinal = 1
Avoid deeply nested control flow statements. Open
Open
if path[n] == '.' {
break
}
Avoid deeply nested control flow statements. Open
Open
if hasMorePartial {
msg.PLogMetaData = &types.PartialLogMetaData{ID: partialid, Ordinal: ordinal, Last: true}
// reset
partialid = ""
Method Daemon.Kill
has 7 return statements (exceeds 4 allowed). Open
Open
func (daemon *Daemon) Kill(container *containerpkg.Container) error {
if !container.IsRunning() {
return errNotRunning(container.ID)
}
Avoid deeply nested control flow statements. Open
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))
}
Function New
has 7 return statements (exceeds 4 allowed). Open
Open
func New(info logger.Info) (logger.Logger, error) {
tag, err := loggerutils.ParseLogTag(info, loggerutils.DefaultTemplate)
if err != nil {
return nil, err
}
Function getService
has 7 return statements (exceeds 4 allowed). Open
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
}
Method reader.wait
has 7 return statements (exceeds 4 allowed). Open
Open
func (r *reader) wait(ctx context.Context) (bool, error) {
deadline := r.drainDeadline
if d, ok := ctx.Deadline(); ok && d.Before(deadline) {
deadline = d
}
Method reader.drainJournal
has 7 return statements (exceeds 4 allowed). Open
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 {
Function parseAddress
has 7 return statements (exceeds 4 allowed). Open
Open
func parseAddress(address string) (string, string, error) {
if address == "" {
return "", "", nil
}
addr, err := url.Parse(address)
Avoid deeply nested control flow statements. Open
Open
for ; n < l; n++ {
if os.IsPathSeparator(path[n]) {
break
}
}
Function validateHealthCheck
has 7 return statements (exceeds 4 allowed). Open
Open
func validateHealthCheck(healthConfig *containertypes.HealthConfig) error {
if healthConfig == nil {
return nil
}
if healthConfig.Interval != 0 && healthConfig.Interval < containertypes.MinimumDuration {
Method splunkLogger.postMessages
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (l *splunkLogger) postMessages(messages []*splunkMessage, lastChance bool) []*splunkMessage {
messagesLen := len(messages)
ctx, cancel := context.WithTimeout(context.Background(), batchSendTimeout)
defer cancel()
- Read upRead up
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
Open
if err != io.EOF {
logReadsFailedCount.Inc(1)
log.G(context.TODO()).Errorf("Error scanning log stream: %s", err)
return
}
Function ValidateLogOpt
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func ValidateLogOpt(cfg map[string]string) error {
for key := range cfg {
switch key {
case logGroupKey:
case logStreamKey:
- Read upRead up
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
Open
func newStreamConfig(info logger.Info) (*logStreamConfig, error) {
logGroupName := info.Config[logGroupKey]
logStreamName, err := loggerutils.ParseLogTag(info, "{{.FullID}}")
if err != nil {
return nil, err
Function parseAddress
has 7 return statements (exceeds 4 allowed). Open
Open
func parseAddress(address string) (*location, error) {
if address == "" {
return &location{
protocol: defaultProtocol,
host: defaultHost,