docker/swarmkit

View on GitHub

Showing 1,008 of 1,820 total issues

Object has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

type Object struct {
    // Types that are valid to be assigned to Object:
    //    *Object_Node
    //    *Object_Service
    //    *Object_Network
Severity: Minor
Found in api/watch.pb.go - About 3 hrs to fix

    StoreAction has 28 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type StoreAction struct {
        Action StoreActionKind `protobuf:"varint,1,opt,name=action,proto3,enum=docker.swarmkit.v1.StoreActionKind" json:"action,omitempty"`
        // Types that are valid to be assigned to Target:
        //    *StoreAction_Node
        //    *StoreAction_Service
    Severity: Minor
    Found in api/raft.pb.go - About 3 hrs to fix

      Function ConvertTaskWatch has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
      Open

      func ConvertTaskWatch(action WatchActionKind, filters []*SelectBy) ([]Event, error) {
          var (
              m               Task
              checkFuncs      []TaskCheckFunc
              hasDesiredState bool
      Severity: Minor
      Found in api/objects.pb.go - About 3 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 Assignment.Unmarshal has 37 return statements (exceeds 4 allowed).
      Open

      func (m *Assignment) Unmarshal(dAtA []byte) error {
          l := len(dAtA)
          iNdEx := 0
          for iNdEx < l {
              preIndex := iNdEx
      Severity: Major
      Found in api/dispatcher.pb.go - About 3 hrs to fix

        Method Server.ListTasks has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
        Open

        func (s *Server) ListTasks(ctx context.Context, request *api.ListTasksRequest) (*api.ListTasksResponse, error) {
            var (
                tasks []*api.Task
                err   error
            )
        Severity: Minor
        Found in manager/controlapi/task.go - About 3 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.Run has 106 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (d *Dispatcher) Run(ctx context.Context) error {
            ctx = log.WithModule(ctx, "dispatcher")
            log.G(ctx).Info("dispatcher starting")
        
            d.taskUpdatesLock.Lock()
        Severity: Major
        Found in manager/dispatcher/dispatcher.go - About 3 hrs to fix

          Method SecretSpec.Unmarshal has 36 return statements (exceeds 4 allowed).
          Open

          func (m *SecretSpec) Unmarshal(dAtA []byte) error {
              l := len(dAtA)
              iNdEx := 0
              for iNdEx < l {
                  preIndex := iNdEx
          Severity: Major
          Found in api/specs.pb.go - About 3 hrs to fix

            Method Dispatcher.Tasks has 104 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (d *Dispatcher) Tasks(r *api.TasksRequest, stream api.Dispatcher_TasksServer) error {
                d.rpcRW.RLock()
                defer d.rpcRW.RUnlock()
            
                dctx, err := d.isRunningLocked()
            Severity: Major
            Found in manager/dispatcher/dispatcher.go - About 3 hrs to fix

              Function reconcileTaskState has 103 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func reconcileTaskState(ctx context.Context, w *worker, assignments []*api.AssignmentChange, fullSnapshot bool) error {
                  var (
                      updatedTasks []*api.Task
                      removedTasks []*api.Task
                  )
              Severity: Major
              Found in agent/worker.go - About 3 hrs to fix

                Function WatchMessageEvent has 103 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func WatchMessageEvent(c Event) *WatchMessage_Event {
                    switch v := c.(type) {
                    case EventCreateNode:
                        return &WatchMessage_Event{Action: WatchActionKindCreate, Object: &Object{Object: &Object_Node{Node: v.Node}}}
                    case EventUpdateNode:
                Severity: Major
                Found in api/objects.pb.go - About 3 hrs to fix

                  Method Scheduler.applySchedulingDecisions has 103 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (s *Scheduler) applySchedulingDecisions(ctx context.Context, schedulingDecisions map[string]schedulingDecision) (successful, failed []schedulingDecision) {
                      // applySchedulingDecisions is the only place where we make store
                      // transactions in the scheduler. the scheduler is responsible for freeing
                      // volumes that are no longer in use. this means that volumes should be
                      // freed in this function. sometimes, there are no scheduling decisions to
                  Severity: Major
                  Found in manager/scheduler/scheduler.go - About 3 hrs to fix

                    Method Extension.Unmarshal has 35 return statements (exceeds 4 allowed).
                    Open

                    func (m *Extension) Unmarshal(dAtA []byte) error {
                        l := len(dAtA)
                        iNdEx := 0
                        for iNdEx < l {
                            preIndex := iNdEx
                    Severity: Major
                    Found in api/objects.pb.go - About 3 hrs to fix

                      Method Server.UpdateService has a Cognitive Complexity of 37 (exceeds 20 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: Minor
                      Found in manager/controlapi/service.go - About 3 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 AssignmentChange.Unmarshal has 102 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (m *AssignmentChange) Unmarshal(dAtA []byte) error {
                          l := len(dAtA)
                          iNdEx := 0
                          for iNdEx < l {
                              preIndex := iNdEx
                      Severity: Major
                      Found in api/dispatcher.pb.go - About 3 hrs to fix

                        Method Server.Run has 102 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (s *Server) Run(ctx context.Context) error {
                            s.mu.Lock()
                            if s.isRunning() {
                                s.mu.Unlock()
                                return errors.New("CA signer is already running")
                        Severity: Major
                        Found in ca/server.go - About 3 hrs to fix

                          Method EndpointSpec.Unmarshal has 100 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (m *EndpointSpec) Unmarshal(dAtA []byte) error {
                              l := len(dAtA)
                              iNdEx := 0
                              for iNdEx < l {
                                  preIndex := iNdEx
                          Severity: Major
                          Found in api/specs.pb.go - About 3 hrs to fix

                            Method TLSAuthorization.Unmarshal has 100 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (m *TLSAuthorization) Unmarshal(dAtA []byte) error {
                                l := len(dAtA)
                                iNdEx := 0
                                for iNdEx < l {
                                    preIndex := iNdEx
                            Severity: Major
                            Found in protobuf/plugin/plugin.pb.go - About 3 hrs to fix

                              Function CheckTasks has 100 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func CheckTasks(ctx context.Context, s *store.MemoryStore, readTx store.ReadTx, initHandler InitHandler, startSupervisor restart.SupervisorInterface) error {
                                  instances := make(map[orchestrator.SlotTuple][]*api.Task)
                                  err := s.Batch(func(batch *store.Batch) error {
                                      tasks, err := store.FindTasks(readTx, store.All)
                                      if err != nil {
                              Severity: Major
                              Found in manager/orchestrator/taskinit/init.go - About 3 hrs to fix

                                Method InternalRaftRequest.Unmarshal has 100 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func (m *InternalRaftRequest) Unmarshal(dAtA []byte) error {
                                    l := len(dAtA)
                                    iNdEx := 0
                                    for iNdEx < l {
                                        preIndex := iNdEx
                                Severity: Major
                                Found in api/raft.pb.go - About 3 hrs to fix

                                  Allocator has 26 methods (exceeds 20 allowed). Consider refactoring.
                                  Open

                                  func (a *Allocator) doNetworkInit(ctx context.Context) (err error) {
                                      nc := &networkContext{
                                          nwkAllocator:        a.nwkAllocator,
                                          portAllocator:       newPortAllocator(),
                                          pendingTasks:        make(map[string]*api.Task),
                                  Severity: Minor
                                  Found in manager/allocator/network.go - About 3 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language