docker/swarmkit

View on GitHub

Showing 1,008 of 1,820 total issues

Method taskManager.run has 129 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (tm *taskManager) run(ctx context.Context) {
    ctx, cancelAll := context.WithCancel(ctx)
    defer cancelAll() // cancel all child operations on exit.

    ctx = log.WithModule(ctx, "taskmanager")
Severity: Major
Found in agent/task.go - About 4 hrs to fix

    Function printServiceSummary has 129 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func printServiceSummary(service *api.Service, running int) {
        w := tabwriter.NewWriter(os.Stdout, 8, 8, 8, ' ', 0)
        defer w.Flush()
    
        task := service.Spec.Task
    Severity: Major
    Found in swarmd/cmd/swarmctl/service/inspect.go - About 4 hrs to fix

      Method nodeSet.tree has a Cognitive Complexity of 43 (exceeds 20 allowed). Consider refactoring.
      Open

      func (ns *nodeSet) tree(serviceID string, preferences []*api.PlacementPreference, maxAssignments int, meetsConstraints func(*NodeInfo) bool, nodeLess func(*NodeInfo, *NodeInfo) bool) decisionTree {
          var root decisionTree
      
          if maxAssignments == 0 {
              return root
      Severity: Minor
      Found in manager/scheduler/nodeset.go - About 4 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.processUpdates has 127 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (d *Dispatcher) processUpdates(ctx context.Context) {
          var (
              taskUpdates        map[string]*api.TaskStatus
              nodeUpdates        map[string]nodeUpdate
              unpublishedVolumes map[string][]string
      Severity: Major
      Found in manager/dispatcher/dispatcher.go - About 4 hrs to fix

        Method Network.Unmarshal has 46 return statements (exceeds 4 allowed).
        Open

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

          Method Volume.Unmarshal has 46 return statements (exceeds 4 allowed).
          Open

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

            Method Dispatcher.Session has 125 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

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

              Method testSuite.TestAllocatorRestartNoEndpointSpec has 124 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (suite *testSuite) TestAllocatorRestartNoEndpointSpec() {
                  s := store.NewMemoryStore(nil)
                  suite.NotNil(s)
                  defer s.Close()
                  // Create 3 services with 1 task each
              Severity: Major
              Found in manager/allocator/allocator_test_suite.go - About 3 hrs to fix

                Method Orchestrator.reconcileOneNode has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
                Open

                func (g *Orchestrator) reconcileOneNode(ctx context.Context, node *api.Node) {
                    if node.Spec.Availability == api.NodeAvailabilityDrain {
                        log.G(ctx).Debugf("global orchestrator: node %s in drain state, shutting down its tasks", node.ID)
                        g.foreachTaskFromNode(ctx, node, g.shutdownTask)
                        return
                Severity: Minor
                Found in manager/orchestrator/global/global.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 Server.checkPortConflicts has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
                Open

                func (s *Server) checkPortConflicts(spec *api.ServiceSpec, serviceID string) error {
                    if spec.Endpoint == nil {
                        return 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 readTx.findIterators has 45 return statements (exceeds 4 allowed).
                Open

                func (tx readTx) findIterators(table string, by By, checkType func(By) error) ([]memdb.ResultIterator, error) {
                    switch by.(type) {
                    case byAll, orCombinator: // generic types
                    default: // all other types
                        if err := checkType(by); err != nil {
                Severity: Major
                Found in manager/state/store/memory.go - About 3 hrs to fix

                  Method NodeCertificateStatusResponse.Unmarshal has 119 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

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

                    Function parseUpdate has 119 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func parseUpdate(flags *pflag.FlagSet, spec *api.ServiceSpec) error {
                        if flags.Changed("update-parallelism") {
                            parallelism, err := flags.GetUint64("update-parallelism")
                            if err != nil {
                                return err
                    Severity: Major
                    Found in swarmd/cmd/swarmctl/service/flagparser/update.go - About 3 hrs to fix

                      Method SubscribeLogsRequest.Unmarshal has 119 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

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

                        Method Dispatcher.Session has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func (d *Dispatcher) Session(r *api.SessionRequest, stream api.Dispatcher_SessionServer) error {
                            d.rpcRW.RLock()
                            defer d.rpcRW.RUnlock()
                        
                            dctx, err := d.isRunningLocked()
                        Severity: Minor
                        Found in manager/dispatcher/dispatcher.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 ContainerSpec_Ulimit.Unmarshal has 117 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (m *ContainerSpec_Ulimit) 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 WatchMessage.Unmarshal has 117 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

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

                            Method Reconciler.ReconcileService has 117 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (r *Reconciler) ReconcileService(id string) error {
                                var (
                                    service *api.Service
                                    tasks   []*api.Task
                                    cluster *api.Cluster
                            Severity: Major
                            Found in manager/orchestrator/jobs/replicated/reconciler.go - About 3 hrs to fix

                              Method SessionMessage.Unmarshal has 42 return statements (exceeds 4 allowed).
                              Open

                              func (m *SessionMessage) 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 Resource.Unmarshal has 42 return statements (exceeds 4 allowed).
                                Open

                                func (m *Resource) 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
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language