Showing 1,008 of 1,820 total issues
Method Dispatcher.markNodesUnknown
has 8 return statements (exceeds 4 allowed). Open
Open
func (d *Dispatcher) markNodesUnknown(ctx context.Context) error {
log := log.G(ctx).WithField("method", "(*Dispatcher).markNodesUnknown")
var nodes []*api.Node
var err error
d.store.View(func(tx store.ReadTx) {
Method LogBroker.ListenSubscriptions
has 8 return statements (exceeds 4 allowed). Open
Open
func (lb *LogBroker) ListenSubscriptions(request *api.ListenSubscriptionsRequest, stream api.LogBroker_ListenSubscriptionsServer) error {
remote, err := ca.RemoteNode(stream.Context())
if err != nil {
return err
}
Method Node.loadAndStart
has 8 return statements (exceeds 4 allowed). Open
Open
func (n *Node) loadAndStart(ctx context.Context, forceNewCluster bool) error {
snapshot, waldata, err := n.readFromDisk(ctx)
if err != nil {
return err
}
Method LogBroker.PublishLogs
has 8 return statements (exceeds 4 allowed). Open
Open
func (lb *LogBroker) PublishLogs(stream api.LogBroker_PublishLogsServer) (err error) {
remote, err := ca.RemoteNode(stream.Context())
if err != nil {
return err
}
Method portAllocator.isPortsAllocatedOnInit
has 8 return statements (exceeds 4 allowed). Open
Open
func (pa *portAllocator) isPortsAllocatedOnInit(s *api.Service, onInit bool) bool {
// If service has no user-defined endpoint and allocated endpoint,
// we assume it is allocated and return true.
if s.Endpoint == nil && s.Spec.Endpoint == nil {
return true
Method Allocator.allocateTask
has 8 return statements (exceeds 4 allowed). Open
Open
func (a *Allocator) allocateTask(ctx context.Context, t *api.Task) (err error) {
taskUpdated := false
nc := a.netCtx
logger := log.G(ctx).WithField("method", "(*Allocator).allocateTask")
Method Node.JoinAndStart
has 8 return statements (exceeds 4 allowed). Open
Open
func (n *Node) JoinAndStart(ctx context.Context) (err error) {
ctx, cancel := n.WithContext(ctx)
defer func() {
cancel()
if err != nil {
Avoid deeply nested control flow statements. Open
Open
if err != nil {
return err
}
Function decryptRaftData
has 7 return statements (exceeds 4 allowed). Open
Open
func decryptRaftData(swarmdir, outdir, unlockKey string) error {
krw, err := getKRW(swarmdir, unlockKey)
if err != nil {
return err
}
Method StubAPIClient.ContainerCreate
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (sa *StubAPIClient) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networking *network.NetworkingConfig, platform *v1.Platform, containerName string) (container.CreateResponse, error) {
Avoid deeply nested control flow statements. Open
Open
switch suffix {
case 'g':
multiplier = 1 << 30
case 'm':
multiplier = 1 << 20
Avoid deeply nested control flow statements. Open
Open
if container := actype.Task.Spec.GetContainer(); container != nil {
container.Env = []string{"ENVVARS REDACTED"}
if container.PullOptions != nil {
container.PullOptions.RegistryAuth = "REDACTED"
}
Function parseTmpfs
has 7 return statements (exceeds 4 allowed). Open
Open
func parseTmpfs(flags *pflag.FlagSet, spec *api.ServiceSpec) error {
if flags.Changed("tmpfs") {
tmpfss, err := flags.GetStringSlice("tmpfs")
if err != nil {
return err
Method nodePlugin.NodeUnstageVolume
has 7 return statements (exceeds 4 allowed). Open
Open
func (np *nodePlugin) NodeUnstageVolume(ctx context.Context, req *api.VolumeAssignment) error {
np.mu.Lock()
defer np.mu.Unlock()
if !np.staging {
return nil
Avoid deeply nested control flow statements. Open
Open
if container := actype.Service.Spec.Task.GetContainer(); container != nil {
container.Env = []string{"ENVVARS REDACTED"}
if container.PullOptions != nil {
container.PullOptions.RegistryAuth = "REDACTED"
}
Function parseRestart
has 7 return statements (exceeds 4 allowed). Open
Open
func parseRestart(flags *pflag.FlagSet, spec *api.ServiceSpec) error {
if spec.Task.Restart == nil {
// set new service's restart policy as RestartOnAny
spec.Task.Restart = &api.RestartPolicy{
Condition: api.RestartOnAny,
Method controller.Remove
has 7 return statements (exceeds 4 allowed). Open
Open
func (r *controller) Remove(ctx context.Context) error {
if err := r.checkClosed(); err != nil {
return err
}
Method Cluster.MarshalToSizedBuffer
has 7 return statements (exceeds 4 allowed). Open
Open
func (m *Cluster) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
Avoid deeply nested control flow statements. Open
Open
if intStringLenmapkey < 0 {
return ErrInvalidLengthObjects
}
Avoid deeply nested control flow statements. Open
Open
if shift >= 64 {
return ErrIntOverflowObjects
}