Showing 1,904 of 1,904 total issues
Method Daemon.setupConfigDir
has 7 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) setupConfigDir(ctr *container.Container) (setupErr error) {
if len(ctr.ConfigReferences) == 0 {
return nil
}
Avoid deeply nested control flow statements. Open
if hasMorePartial {
msg.PLogMetaData = &types.PartialLogMetaData{ID: partialid, Ordinal: ordinal, Last: true}
// reset
partialid = ""
Avoid deeply nested control flow statements. Open
if msg.PLogMetaData == nil {
msg.Timestamp = time.Now().UTC()
} else {
msg.Timestamp = partialTS
}
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)
Function parseAddress
has 7 return statements (exceeds 4 allowed). Open
func parseAddress(address string) (*location, error) {
if address == "" {
return &location{
protocol: defaultProtocol,
host: defaultHost,
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()
- 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
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
}
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
}
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
}
Avoid deeply nested control flow statements. Open
for ; n < l; n++ {
if os.IsPathSeparator(path[n]) {
break
}
}
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:
- 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
if logErr := c.dst.Log(msg); logErr != nil {
logDriverError(c.dst.Name(), string(msg.Line), logErr)
}
Method Daemon.initializeNetworkingPaths
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (daemon *Daemon) initializeNetworkingPaths(ctr *container.Container, nc *container.Container) error {
if nc.HostConfig.Isolation.IsHyperV() {
return fmt.Errorf("sharing of hyperv containers network is not supported")
}
- 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
if logErr := c.dst.Log(msg); logErr != nil {
logDriverError(c.dst.Name(), string(msg.Line), logErr)
}
Avoid deeply nested control flow statements. Open
if jsonEvent, err := json.Marshal(messages[j]); err != nil {
log.G(ctx).Error(err)
} else {
log.G(ctx).Error(fmt.Errorf("Failed to send a message '%s'", string(jsonEvent)))
}
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
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
}
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) {
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 {
Method Daemon.newContainer
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func (daemon *Daemon) newContainer(name string, operatingSystem string, config *containertypes.Config, hostConfig *containertypes.HostConfig, imgID image.ID, managed bool) (*container.Container, error) {