Showing 1,468 of 1,914 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
}
Method Daemon.registerName
has 5 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) registerName(container *container.Container) error {
if container.ID == "" {
return fmt.Errorf("invalid empty id")
}
if daemon.containers.Get(container.ID) != nil {
Function New
has 5 return statements (exceeds 4 allowed). Open
func New(info logger.Info) (logger.Logger, error) {
initGCP()
var project string
if projectID != "" {
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 validateContainerConfig
has 5 return statements (exceeds 4 allowed). Open
func validateContainerConfig(config *containertypes.Config) error {
if config == nil {
return nil
}
if err := translateWorkingDir(config); err != nil {
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
Function parseAddress
has 5 return statements (exceeds 4 allowed). Open
func parseAddress(address string) (*url.URL, error) {
if address == "" {
return nil, fmt.Errorf("gelf-address is a required parameter")
}
addr, err := url.Parse(address)
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
}
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
Method Daemon.killWithSignal
has 5 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) killWithSignal(container *containerpkg.Container, stopSignal syscall.Signal) error {
log.G(context.TODO()).WithFields(log.Fields{
"signal": int(stopSignal),
"container": container.ID,
}).Debugf("sending signal %[1]d (%[1]s) to container", stopSignal)
Function NodeFromGRPC
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func NodeFromGRPC(n swarmapi.Node) types.Node {
node := types.Node{
ID: n.ID,
Spec: types.NodeSpec{
Role: types.NodeRole(strings.ToLower(n.Spec.DesiredRole.String())),
- 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 splunkLogger.tryPostMessages
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (l *splunkLogger) tryPostMessages(ctx context.Context, messages []*splunkMessage) error {
if len(messages) == 0 {
return nil
}
var buffer bytes.Buffer
- 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 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)
}
Function containerToGRPC
has 5 return statements (exceeds 4 allowed). Open
func containerToGRPC(c *types.ContainerSpec) (*swarmapi.ContainerSpec, error) {
containerSpec := &swarmapi.ContainerSpec{
Image: c.Image,
Labels: c.Labels,
Command: c.Command,
Method follow.Do
has 5 return statements (exceeds 4 allowed). Open
func (fl *follow) Do(ctx context.Context, f *os.File, read logPos) {
fl.log = log.G(ctx).WithFields(log.Fields{
"module": "logger",
"file": f.Name(),
})
Method Daemon.ContainerKill
has 5 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) ContainerKill(name, stopSignal string) error {
var (
err error
sig = syscall.SIGKILL
)
Function getUntilFromPruneFilters
has 5 return statements (exceeds 4 allowed). Open
func getUntilFromPruneFilters(pruneFilters filters.Args) (time.Time, error) {
until := time.Time{}
if !pruneFilters.Contains("until") {
return until, nil
}
Method Daemon.updateNetworkSettings
has 5 return statements (exceeds 4 allowed). Open
func (daemon *Daemon) updateNetworkSettings(ctr *container.Container, n *libnetwork.Network, endpointConfig *networktypes.EndpointSettings) error {
if ctr.NetworkSettings == nil {
ctr.NetworkSettings = &network.Settings{}
}
if ctr.NetworkSettings.Networks == nil {
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
}
Function copyRegular
has 5 return statements (exceeds 4 allowed). Open
func copyRegular(srcPath, dstPath string, fileinfo os.FileInfo, copyWithFileRange, copyWithFileClone *bool) error {
srcFile, err := os.Open(srcPath)
if err != nil {
return err
}