Showing 1,008 of 1,820 total issues
Avoid deeply nested control flow statements. Open
Open
if packedLen < 0 {
return ErrInvalidLengthRaft
}
Avoid deeply nested control flow statements. Open
Open
if postIndex > l {
return io.ErrUnexpectedEOF
}
Method Orchestrator.addTasks
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (r *Orchestrator) addTasks(ctx context.Context, batch *store.Batch, service *api.Service, runningSlots map[uint64]orchestrator.Slot, deadSlots map[uint64]orchestrator.Slot, count uint64) {
Avoid deeply nested control flow statements. Open
Open
if shift >= 64 {
return ErrIntOverflowRaft
}
Avoid deeply nested control flow statements. Open
Open
if elementCount != 0 && len(m.RemovedMembers) == 0 {
m.RemovedMembers = make([]uint64, 0, elementCount)
}
Avoid deeply nested control flow statements. Open
Open
for iNdEx < postIndex {
var v uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowRaft
Method Updater.Run
has 7 return statements (exceeds 4 allowed). Open
Open
func (u *Updater) Run(ctx context.Context, slots []orchestrator.Slot) {
defer close(u.doneChan)
service := u.newService
Method Orchestrator.tickTasks
has 7 return statements (exceeds 4 allowed). Open
Open
func (g *Orchestrator) tickTasks(ctx context.Context) {
if len(g.restartTasks) == 0 {
return
}
err := g.store.Batch(func(batch *store.Batch) error {
Avoid deeply nested control flow statements. Open
Open
if err != nil {
log.G(ctx).WithError(err).WithField("task.id", updated.ID).Warning("failed to remove old task after starting replacement")
}
Method Scheduler.scheduleNTasksOnSubtree
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (s *Scheduler) scheduleNTasksOnSubtree(ctx context.Context, n int, taskGroup map[string]*api.Task, tree *decisionTree, schedulingDecisions map[string]schedulingDecision, nodeLess func(a *NodeInfo, b *NodeInfo) bool) int {
Avoid deeply nested control flow statements. Open
Open
if status.NodeID == nodeID {
if assignments.addOrUpdateVolume(readTx, vol) {
oneModification()
}
}
Method Server.CreateService
has 7 return statements (exceeds 4 allowed). Open
Open
func (s *Server) CreateService(ctx context.Context, request *api.CreateServiceRequest) (*api.CreateServiceResponse, error) {
if err := validateServiceSpec(request.Spec); err != nil {
return nil, err
}
Avoid deeply nested control flow statements. Open
Open
if !request.IncludeOldObject {
eventMessage.OldObject = nil
}
Method Scheduler.updateTask
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (s *Scheduler) updateTask(ctx context.Context, t *api.Task) bool {
// Ignore all tasks that have not reached PENDING
// state.
if t.Status.State < api.TaskStatePending {
return false
- 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 assignments.removeTask(readTx, v.Task) {
oneModification()
}
Method Scheduler.scheduleNTasksOnNodes
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (s *Scheduler) scheduleNTasksOnNodes(ctx context.Context, n int, taskGroup map[string]*api.Task, nodes []NodeInfo, schedulingDecisions map[string]schedulingDecision, nodeLess func(a *NodeInfo, b *NodeInfo) bool) int {
Function validateConfigRefsSpec
has 7 return statements (exceeds 4 allowed). Open
Open
func validateConfigRefsSpec(spec api.TaskSpec) error {
container := spec.GetContainer()
if container == nil {
return nil
}
Function watchNode
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func watchNode(t *testing.T, watch chan events.Event, expectTimeout bool,
fn func(t assert.TestingT, originalNode, updatedNode *api.Node, networks []string) bool,
originalNode *api.Node,
networks []string) {
Function validateServiceSpec
has 7 return statements (exceeds 4 allowed). Open
Open
func validateServiceSpec(spec *api.ServiceSpec) error {
if spec == nil {
return status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
}
if err := validateAnnotations(spec.Annotations); err != nil {
Function newRootRotationObject
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func newRootRotationObject(ctx context.Context, securityConfig *ca.SecurityConfig, apiRootCA *api.RootCA, newCARootCA ca.RootCA, extCAs []*api.ExternalCA, version uint64) (*api.RootCA, error) {