docker/swarmkit

View on GitHub

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 {
Severity: Minor
Found in manager/orchestrator/replicated/tasks.go - About 2 hrs to fix

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) {
Severity: Minor
Found in manager/dispatcher/dispatcher.go - About 2 hrs to fix

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
Severity: Minor
Found in manager/scheduler/scheduler.go - About 2 hrs to fix

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
Severity: Major
Found in api/objects.pb.go - About 2 hrs to fix

    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
    Severity: Major
    Found in api/specs.pb.go - About 2 hrs to fix

      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
      Severity: Major
      Found in api/specs.pb.go - About 2 hrs to fix

        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 {
        Severity: Major
        Found in manager/controlapi/service.go - About 2 hrs to fix

          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
          Severity: Major
          Found in api/specs.pb.go - About 2 hrs to fix

            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})
            Severity: Major
            Found in manager/scheduler/scheduler.go - About 2 hrs to fix

              containerConfig has 22 methods (exceeds 20 allowed). Consider refactoring.
              Open

              type containerConfig struct {
                  task                *api.Task
                  networksAttachments map[string]*api.NetworkAttachment
              }
              Severity: Minor
              Found in swarmd/dockerexec/container.go - About 2 hrs to fix

                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
                Severity: Major
                Found in api/snapshot.pb.go - About 2 hrs to fix

                  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
                  Severity: Minor
                  Found in api/dispatcher.pb.go - About 2 hrs to fix

                    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
                    Severity: Major
                    Found in api/snapshot.pb.go - About 2 hrs to fix

                      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
                      Severity: Major
                      Found in api/watch.pb.go - About 2 hrs to fix

                        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:
                        Severity: Minor
                        Found in api/specs.pb.go - About 2 hrs to fix

                          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
                          Severity: Major
                          Found in api/watch.pb.go - About 2 hrs to fix

                            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
                            Severity: Major
                            Found in api/raft.pb.go - About 2 hrs to fix

                              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
                              Severity: Major
                              Found in api/raft.pb.go - About 2 hrs to fix

                                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
                                Severity: Major
                                Found in api/raft.pb.go - About 2 hrs to fix

                                  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.
                                  Severity: Major
                                  Found in manager/orchestrator/taskreaper/task_reaper.go - About 2 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language