docker/swarmkit

View on GitHub

Showing 1,008 of 1,820 total issues

Method deepCopyGen.genMsgDeepCopy has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
Open

func (d *deepCopyGen) genMsgDeepCopy(m *generator.Descriptor) {
    ccTypeName := generator.CamelCaseSlice(m.TypeName())

    // Generate backwards compatible, type-safe Copy() function.
    d.P("func (m *", ccTypeName, ") Copy() *", ccTypeName, "{")
Severity: Minor
Found in protobuf/plugin/deepcopy/deepcopy.go - About 1 hr 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 Orchestrator.Run has a Cognitive Complexity of 28 (exceeds 20 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: Minor
Found in manager/orchestrator/global/global.go - About 1 hr 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 Manager.handleVolume has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
Open

func (vm *Manager) handleVolume(ctx context.Context, id string) error {
    var volume *api.Volume
    vm.store.View(func(tx store.ReadTx) {
        volume = store.GetVolume(tx, id)
    })
Severity: Minor
Found in manager/csi/manager.go - About 1 hr 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 validateCAConfig has 17 return statements (exceeds 4 allowed).
Open

func validateCAConfig(ctx context.Context, securityConfig *ca.SecurityConfig, cluster *api.Cluster) (*api.RootCA, error) {
    newConfig := cluster.Spec.CAConfig.Copy()
    newConfig.SigningCACert = ca.NormalizePEMs(newConfig.SigningCACert) // ensure this is normalized before we use it

    if len(newConfig.SigningCAKey) > 0 && len(newConfig.SigningCACert) == 0 {
Severity: Major
Found in manager/controlapi/ca_rotation.go - About 1 hr to fix

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

    func (c *Collector) Run(ctx context.Context) error {
        defer close(c.doneChan)
    
        watcher, cancel, err := store.ViewAndWatch(c.store, func(readTx store.ReadTx) error {
            nodes, err := store.FindNodes(readTx, store.All)
    Severity: Minor
    Found in manager/metrics/collector.go - About 1 hr 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 renewCerts has 64 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func renewCerts(swarmdir, unlockKey string) error {
        // First, load the existing cert.  We don't actually bother to check if
        // it's expired - this will just obtain a new cert anyway.
        krw, err := getKRW(swarmdir, unlockKey)
        if err != nil {
    Severity: Minor
    Found in swarmd/cmd/swarm-rafttool/renewcert.go - About 1 hr to fix

      Method Server.UpdateCluster has 64 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (s *Server) UpdateCluster(ctx context.Context, request *api.UpdateClusterRequest) (*api.UpdateClusterResponse, error) {
          if request.ClusterID == "" || request.ClusterVersion == nil {
              return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
          }
          if err := validateClusterSpec(request.Spec); err != nil {
      Severity: Minor
      Found in manager/controlapi/cluster.go - About 1 hr to fix

        Method Allocator.doTaskAlloc has 63 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (a *Allocator) doTaskAlloc(ctx context.Context, ev events.Event) {
            var (
                isDelete bool
                t        *api.Task
            )
        Severity: Minor
        Found in manager/allocator/network.go - About 1 hr to fix

          Method HeartbeatResponse.Unmarshal has 16 return statements (exceeds 4 allowed).
          Open

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

            Method TasksMessage.Unmarshal has 16 return statements (exceeds 4 allowed).
            Open

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

              Method SubscribeLogsMessage.Unmarshal has 16 return statements (exceeds 4 allowed).
              Open

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

                Method StreamRaftMessageRequest.Unmarshal has 16 return statements (exceeds 4 allowed).
                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 1 hr to fix

                  Method LeaveRequest.Unmarshal has 16 return statements (exceeds 4 allowed).
                  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 1 hr to fix

                    Method ProcessRaftMessageRequest.Unmarshal has 16 return statements (exceeds 4 allowed).
                    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 1 hr to fix

                      Method Server.UpdateService has 16 return statements (exceeds 4 allowed).
                      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 1 hr to fix

                        Function NodeMatches has 16 return statements (exceeds 4 allowed).
                        Open

                        func NodeMatches(constraints []Constraint, n *api.Node) bool {
                            for _, constraint := range constraints {
                                switch {
                                case strings.EqualFold(constraint.key, "node.id"):
                                    if !constraint.Match(n.ID) {
                        Severity: Major
                        Found in manager/constraint/constraint.go - About 1 hr to fix

                          Method Server.NodeCertificateStatus has 62 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (s *Server) NodeCertificateStatus(ctx context.Context, request *api.NodeCertificateStatusRequest) (*api.NodeCertificateStatusResponse, error) {
                              if request.NodeID == "" {
                                  return nil, status.Errorf(codes.InvalidArgument, codes.InvalidArgument.String())
                              }
                          
                          
                          Severity: Minor
                          Found in ca/server.go - About 1 hr to fix

                            Method controller.Start has 61 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (r *controller) Start(ctx context.Context) error {
                                if err := r.checkClosed(); err != nil {
                                    return err
                                }
                            
                            
                            Severity: Minor
                            Found in swarmd/dockerexec/controller.go - About 1 hr to fix

                              Method Orchestrator.reconcile has 61 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func (r *Orchestrator) reconcile(ctx context.Context, service *api.Service) {
                                  runningSlots, deadSlots, err := r.updatableAndDeadSlots(ctx, service)
                                  if err != nil {
                                      log.G(ctx).WithError(err).Errorf("reconcile failed finding tasks")
                                      return
                              Severity: Minor
                              Found in manager/orchestrator/replicated/services.go - About 1 hr to fix

                                Method assignmentSet.releaseTaskDependencies has 61 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func (a *assignmentSet) releaseTaskDependencies(readTx store.ReadTx, t *api.Task) bool {
                                    var modified bool
                                
                                    for _, resourceRef := range t.Spec.ResourceReferences {
                                        var assignment *api.Assignment
                                Severity: Minor
                                Found in manager/dispatcher/assignments.go - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language