docker/swarmkit

View on GitHub

Showing 1,008 of 1,820 total issues

Method roleManager.Run has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
Open

func (rm *roleManager) Run(ctx context.Context) {
    defer close(rm.doneChan)

    var (
        nodes []*api.Node
Severity: Minor
Found in manager/role_manager.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 ContainerSpec.CopyFrom has 93 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (m *ContainerSpec) CopyFrom(src interface{}) {

    o := src.(*ContainerSpec)
    *m = *o
    if o.Labels != nil {
Severity: Major
Found in api/specs.pb.go - About 2 hrs to fix

    Method Meta.Unmarshal has 30 return statements (exceeds 4 allowed).
    Open

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

      Method Endpoint.Unmarshal has 30 return statements (exceeds 4 allowed).
      Open

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

        Method TaskReaper.Run has 91 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (tr *TaskReaper) Run(ctx context.Context) {
            watcher, watchCancel := state.Watch(tr.store.WatchQueue(), api.EventCreateTask{}, api.EventUpdateTask{}, api.EventUpdateCluster{})
        
            defer func() {
                close(tr.doneChan)
        Severity: Major
        Found in manager/orchestrator/taskreaper/task_reaper.go - About 2 hrs to fix

          Method Server.signNodeCert has 91 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (s *Server) signNodeCert(ctx context.Context, node *api.Node) error {
              s.signingMu.Lock()
              rootCA := s.localRootCA
              externalCA := s.externalCA
              s.signingMu.Unlock()
          Severity: Major
          Found in ca/server.go - About 2 hrs to fix

            Method Server.IssueNodeCertificate has 91 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (s *Server) IssueNodeCertificate(ctx context.Context, request *api.IssueNodeCertificateRequest) (*api.IssueNodeCertificateResponse, error) {
                // First, let's see if the remote node is presenting a non-empty CSR
                if len(request.CSR) == 0 {
                    return nil, status.Errorf(codes.InvalidArgument, codes.InvalidArgument.String())
                }
            Severity: Major
            Found in ca/server.go - About 2 hrs to fix

              Method Orchestrator.Run has 90 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (g *Orchestrator) Run(ctx context.Context) error {
                  defer close(g.doneChan)
              
                  // Watch changes to services and tasks
                  queue := g.store.WatchQueue()
              Severity: Major
              Found in manager/orchestrator/global/global.go - About 2 hrs to fix

                Method Config.Unmarshal has 29 return statements (exceeds 4 allowed).
                Open

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

                  Method ConfigSpec.Unmarshal has 29 return statements (exceeds 4 allowed).
                  Open

                  func (m *ConfigSpec) 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 Supervisor.shouldRestart has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (r *Supervisor) shouldRestart(ctx context.Context, t *api.Task, service *api.Service) bool {
                        // TODO(aluzzardi): This function should not depend on `service`.
                        // There are 3 possible restart policies.
                        switch orchestrator.RestartCondition(t) {
                        case api.RestartOnAny:
                    Severity: Minor
                    Found in manager/orchestrator/restart/restart.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 JoinResponse.Unmarshal has 29 return statements (exceeds 4 allowed).
                    Open

                    func (m *JoinResponse) 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

                      Function WaitForCluster has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func WaitForCluster(t *testing.T, clockSource *fakeclock.FakeClock, nodes map[uint64]*TestNode) {
                          err := testutils.PollFunc(clockSource, func() error {
                              var prev *etcdraft.Status
                              var leadNode *TestNode
                          nodeLoop:
                      Severity: Minor
                      Found in manager/state/raft/testutils/testutils.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 Allocator.allocateService has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (a *Allocator) allocateService(ctx context.Context, s *api.Service, existingAddressesOnly bool) error {
                          nc := a.netCtx
                      
                          if s.Spec.Endpoint != nil {
                              // service has user-defined endpoint
                      Severity: Minor
                      Found in manager/allocator/network.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 SelectBy.CopyFrom has 89 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (m *SelectBy) CopyFrom(src interface{}) {
                      
                          o := src.(*SelectBy)
                          *m = *o
                          if o.By != nil {
                      Severity: Major
                      Found in api/watch.pb.go - About 2 hrs to fix

                        Method VolumeSpec.MarshalToSizedBuffer has 89 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (m *VolumeSpec) 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.ListTasks has 89 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (s *Server) ListTasks(ctx context.Context, request *api.ListTasksRequest) (*api.ListTasksResponse, error) {
                              var (
                                  tasks []*api.Task
                                  err   error
                              )
                          Severity: Major
                          Found in manager/controlapi/task.go - About 2 hrs to fix

                            File updater.go has 523 lines of code (exceeds 500 allowed). Consider refactoring.
                            Open

                            package update
                            
                            import (
                                "context"
                                "errors"
                            Severity: Minor
                            Found in manager/orchestrator/update/updater.go - About 2 hrs to fix

                              Method NetworkSpec.MarshalToSizedBuffer has 88 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

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

                                func (m *StoreObject) Unmarshal(dAtA []byte) error {
                                    var hasFields [1]uint64
                                    l := len(dAtA)
                                    iNdEx := 0
                                    for iNdEx < l {
                                Severity: Major
                                Found in protobuf/plugin/plugin.pb.go - About 2 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language