Showing 1,008 of 1,820 total issues
Method Orchestrator.tickTasks
has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring. Open
func (r *Orchestrator) tickTasks(ctx context.Context) {
if len(r.restartTasks) > 0 {
err := r.store.Batch(func(batch *store.Batch) error {
for taskID := range r.restartTasks {
err := batch.Update(func(tx store.Tx) error {
- 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 Dispatcher.markNodesUnknown
has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring. 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) {
- 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 Scheduler.scheduleNTasksOnSubtree
has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring. 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 {
if tree.next == nil {
nodes := tree.orderedNodes(s.pipeline.Process, nodeLess)
if len(nodes) == 0 {
return 0
- 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 ConvertTaskWatch
has 85 lines of code (exceeds 50 allowed). Consider refactoring. Open
func ConvertTaskWatch(action WatchActionKind, filters []*SelectBy) ([]Event, error) {
var (
m Task
checkFuncs []TaskCheckFunc
hasDesiredState bool
Method ReplicatedJob.Unmarshal
has 85 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *ReplicatedJob) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method ClusterSpec.MarshalToSizedBuffer
has 85 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *ClusterSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
Method Server.UpdateService
has 85 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *Server) UpdateService(ctx context.Context, request *api.UpdateServiceRequest) (*api.UpdateServiceResponse, error) {
if request.ServiceID == "" || request.ServiceVersion == nil {
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
}
if err := validateServiceSpec(request.Spec); err != nil {
Method ServiceSpec.MarshalToSizedBuffer
has 84 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *ServiceSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
Method Scheduler.Run
has 84 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *Scheduler) Run(pctx context.Context) error {
ctx := log.WithModule(pctx, "scheduler")
defer close(s.doneChan)
s.pipeline.AddFilter(&VolumesFilter{vs: s.volumes})
containerConfig
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
type containerConfig struct {
task *api.Task
networksAttachments map[string]*api.NetworkAttachment
}
Method ClusterSnapshot.Unmarshal
has 26 return statements (exceeds 4 allowed). Open
func (m *ClusterSnapshot) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Assignment
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
type Assignment struct {
// Types that are valid to be assigned to Item:
// *Assignment_Task
// *Assignment_Secret
// *Assignment_Config
Method Snapshot.Unmarshal
has 26 return statements (exceeds 4 allowed). Open
func (m *Snapshot) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method WatchRequest.Unmarshal
has 26 return statements (exceeds 4 allowed). Open
func (m *WatchRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
ServiceSpec
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
type ServiceSpec struct {
Annotations Annotations `protobuf:"bytes,1,opt,name=annotations,proto3" json:"annotations"`
// Task defines the task template this service will spawn.
Task TaskSpec `protobuf:"bytes,2,opt,name=task,proto3" json:"task"`
// Types that are valid to be assigned to Mode:
Method WatchMessage_Event.Unmarshal
has 26 return statements (exceeds 4 allowed). Open
func (m *WatchMessage_Event) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method LeaveRequest.Unmarshal
has 83 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *LeaveRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method StreamRaftMessageRequest.Unmarshal
has 83 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *StreamRaftMessageRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method ProcessRaftMessageRequest.Unmarshal
has 83 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *ProcessRaftMessageRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method TaskReaper.tick
has 82 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (tr *TaskReaper) tick() {
// this signals that a tick has occurred. it exists solely for testing.
if tr.tickSignal != nil {
// try writing to this channel, but if it's full, fall straight through
// and ignore it.