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
}
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
}
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
}
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
}
- 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 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
}
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)
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 {
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()
- 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 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
}
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)
- 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 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(),
})
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
}
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)
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 {
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)
}
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
}
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
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
}
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)
}
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