docker/swarmkit

View on GitHub

Showing 1,008 of 1,820 total issues

Function ConvertNodeWatch has 10 return statements (exceeds 4 allowed).
Open

func ConvertNodeWatch(action WatchActionKind, filters []*SelectBy) ([]Event, error) {
    var (
        m             Node
        checkFuncs    []NodeCheckFunc
        hasRole       bool
Severity: Major
Found in api/objects.pb.go - About 1 hr to fix

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

      Method Supervisor.shouldRestart has 10 return statements (exceeds 4 allowed).
      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: Major
      Found in manager/orchestrator/restart/restart.go - About 1 hr to fix

        Method Server.UpdateNode has 10 return statements (exceeds 4 allowed).
        Open

        func (s *Server) UpdateNode(ctx context.Context, request *api.UpdateNodeRequest) (*api.UpdateNodeResponse, error) {
            if request.NodeID == "" || request.NodeVersion == nil {
                return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
            }
            if err := validateNodeSpec(request.Spec); err != nil {
        Severity: Major
        Found in manager/controlapi/node.go - About 1 hr to fix

          Method Dispatcher.Tasks has 10 return statements (exceeds 4 allowed).
          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 1 hr to fix

            Method testSuite.TestNodeAllocator has 10 return statements (exceeds 4 allowed).
            Open

            func (suite *testSuite) TestNodeAllocator() {
                s := store.NewMemoryStore(nil)
                suite.NotNil(s)
                defer s.Close()
            
            
            Severity: Major
            Found in manager/allocator/allocator_test_suite.go - About 1 hr to fix

              Method raftProxyNodeCAServer.NodeCertificateStatus has 9 return statements (exceeds 4 allowed).
              Open

              func (p *raftProxyNodeCAServer) NodeCertificateStatus(ctx context.Context, r *NodeCertificateStatusRequest) (*NodeCertificateStatusResponse, error) {
              
                  conn, err := p.connSelector.LeaderConn(ctx)
                  if err != nil {
                      if err == raftselector.ErrIsLeader {
              Severity: Major
              Found in api/ca.pb.go - About 55 mins to fix

                Method controller.Wait has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                Open

                func (r *controller) Wait(ctx context.Context) error {
                    if err := r.checkClosed(); err != nil {
                        return err
                    }
                
                
                Severity: Minor
                Found in swarmd/dockerexec/controller.go - About 55 mins 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 raftProxyHealthServer.Check has 9 return statements (exceeds 4 allowed).
                Open

                func (p *raftProxyHealthServer) Check(ctx context.Context, r *HealthCheckRequest) (*HealthCheckResponse, error) {
                
                    conn, err := p.connSelector.LeaderConn(ctx)
                    if err != nil {
                        if err == raftselector.ErrIsLeader {
                Severity: Major
                Found in api/health.pb.go - About 55 mins to fix

                  Method raftProxyNodeCAServer.IssueNodeCertificate has 9 return statements (exceeds 4 allowed).
                  Open

                  func (p *raftProxyNodeCAServer) IssueNodeCertificate(ctx context.Context, r *IssueNodeCertificateRequest) (*IssueNodeCertificateResponse, error) {
                  
                      conn, err := p.connSelector.LeaderConn(ctx)
                      if err != nil {
                          if err == raftselector.ErrIsLeader {
                  Severity: Major
                  Found in api/ca.pb.go - About 55 mins to fix

                    Method raftProxyCAServer.GetUnlockKey has 9 return statements (exceeds 4 allowed).
                    Open

                    func (p *raftProxyCAServer) GetUnlockKey(ctx context.Context, r *GetUnlockKeyRequest) (*GetUnlockKeyResponse, error) {
                    
                        conn, err := p.connSelector.LeaderConn(ctx)
                        if err != nil {
                            if err == raftselector.ErrIsLeader {
                    Severity: Major
                    Found in api/ca.pb.go - About 55 mins to fix

                      Function getMountMask has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func getMountMask(m *api.Mount) string {
                          var maskOpts []string
                          if m.ReadOnly {
                              maskOpts = append(maskOpts, "ro")
                          }
                      Severity: Minor
                      Found in swarmd/dockerexec/container.go - About 55 mins 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 raftProxyCAServer.GetRootCACertificate has 9 return statements (exceeds 4 allowed).
                      Open

                      func (p *raftProxyCAServer) GetRootCACertificate(ctx context.Context, r *GetRootCACertificateRequest) (*GetRootCACertificateResponse, error) {
                      
                          conn, err := p.connSelector.LeaderConn(ctx)
                          if err != nil {
                              if err == raftselector.ErrIsLeader {
                      Severity: Major
                      Found in api/ca.pb.go - About 55 mins to fix

                        Method DetachNetworkResponse.Unmarshal has 9 return statements (exceeds 4 allowed).
                        Open

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

                          Method raftProxyResourceAllocatorServer.DetachNetwork has 9 return statements (exceeds 4 allowed).
                          Open

                          func (p *raftProxyResourceAllocatorServer) DetachNetwork(ctx context.Context, r *DetachNetworkRequest) (*DetachNetworkResponse, error) {
                          
                              conn, err := p.connSelector.LeaderConn(ctx)
                              if err != nil {
                                  if err == raftselector.ErrIsLeader {
                          Severity: Major
                          Found in api/resource.pb.go - About 55 mins to fix

                            Method Node.MarshalToSizedBuffer has 9 return statements (exceeds 4 allowed).
                            Open

                            func (m *Node) MarshalToSizedBuffer(dAtA []byte) (int, error) {
                                i := len(dAtA)
                                _ = i
                                var l int
                                _ = l
                            Severity: Major
                            Found in api/objects.pb.go - About 55 mins to fix

                              Method Service.MarshalToSizedBuffer has 9 return statements (exceeds 4 allowed).
                              Open

                              func (m *Service) MarshalToSizedBuffer(dAtA []byte) (int, error) {
                                  i := len(dAtA)
                                  _ = i
                                  var l int
                                  _ = l
                              Severity: Major
                              Found in api/objects.pb.go - About 55 mins to fix

                                Method raftProxyResourceAllocatorServer.AttachNetwork has 9 return statements (exceeds 4 allowed).
                                Open

                                func (p *raftProxyResourceAllocatorServer) AttachNetwork(ctx context.Context, r *AttachNetworkRequest) (*AttachNetworkResponse, error) {
                                
                                    conn, err := p.connSelector.LeaderConn(ctx)
                                    if err != nil {
                                        if err == raftselector.ErrIsLeader {
                                Severity: Major
                                Found in api/resource.pb.go - About 55 mins to fix

                                  Method GetRootCACertificateRequest.Unmarshal has 9 return statements (exceeds 4 allowed).
                                  Open

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

                                    Method GetUnlockKeyRequest.Unmarshal has 9 return statements (exceeds 4 allowed).
                                    Open

                                    func (m *GetUnlockKeyRequest) Unmarshal(dAtA []byte) error {
                                        l := len(dAtA)
                                        iNdEx := 0
                                        for iNdEx < l {
                                            preIndex := iNdEx
                                    Severity: Major
                                    Found in api/ca.pb.go - About 55 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language