docker/swarmkit

View on GitHub

Showing 1,008 of 1,820 total issues

Method raftProxyRaftMembershipServer.Leave has 9 return statements (exceeds 4 allowed).
Open

func (p *raftProxyRaftMembershipServer) Leave(ctx context.Context, r *LeaveRequest) (*LeaveResponse, error) {

    conn, err := p.connSelector.LeaderConn(ctx)
    if err != nil {
        if err == raftselector.ErrIsLeader {
Severity: Major
Found in api/raft.pb.go - About 55 mins to fix

    Method Server.signNodeCert has 9 return statements (exceeds 4 allowed).
    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 55 mins to fix

      Method Server.NodeCertificateStatus has 9 return statements (exceeds 4 allowed).
      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: Major
      Found in ca/server.go - About 55 mins to fix

        Method Server.ListVolumes has 9 return statements (exceeds 4 allowed).
        Open

        func (s *Server) ListVolumes(ctx context.Context, request *api.ListVolumesRequest) (*api.ListVolumesResponse, error) {
            var (
                volumes []*api.Volume
                err     error
            )
        Severity: Major
        Found in manager/controlapi/volume.go - About 55 mins to fix

          Method Server.CreateVolume has 9 return statements (exceeds 4 allowed).
          Open

          func (s *Server) CreateVolume(ctx context.Context, request *api.CreateVolumeRequest) (*api.CreateVolumeResponse, error) {
              if request.Spec == nil {
                  return nil, status.Errorf(codes.InvalidArgument, "spec must not be nil")
              }
          
          
          Severity: Major
          Found in manager/controlapi/volume.go - About 55 mins to fix

            Function validateTaskSpec has 9 return statements (exceeds 4 allowed).
            Open

            func validateTaskSpec(taskSpec api.TaskSpec) error {
                if err := validateResourceRequirements(taskSpec.Resources); err != nil {
                    return err
                }
            
            
            Severity: Major
            Found in manager/controlapi/service.go - About 55 mins to fix

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

              func (f *PluginFilter) Check(n *NodeInfo) bool {
                  if n.Description == nil || n.Description.Engine == nil {
                      // If the node is not running Engine, plugins are not
                      // supported.
                      return true
              Severity: Minor
              Found in manager/scheduler/filter.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 Allocator.doTaskAlloc has a Cognitive Complexity of 24 (exceeds 20 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 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 subscription.match has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
              Open

              func (s *subscription) match() {
                  s.mu.Lock()
                  defer s.mu.Unlock()
              
                  add := func(t *api.Task) {
              Severity: Minor
              Found in manager/logbroker/subscription.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

              Function WatchFrom has 9 return statements (exceeds 4 allowed).
              Open

              func WatchFrom(store *MemoryStore, version *api.Version, specifiers ...api.Event) (chan events.Event, func(), error) {
                  if version == nil {
                      ch, cancel := state.Watch(store.WatchQueue(), specifiers...)
                      return ch, cancel, nil
                  }
              Severity: Major
              Found in manager/state/store/memory.go - About 55 mins to fix

                Method Allocator.doNetworkInit has 9 return statements (exceeds 4 allowed).
                Open

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

                  Method Collector.Run has 9 return statements (exceeds 4 allowed).
                  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: Major
                  Found in manager/metrics/collector.go - About 55 mins to fix

                    Function updateNode has 8 return statements (exceeds 4 allowed).
                    Open

                    func updateNode(cmd *cobra.Command, args []string) error {
                        if len(args) == 0 {
                            return errors.New("node ID missing")
                        }
                    
                    
                    Severity: Major
                    Found in swarmd/cmd/swarmctl/node/common.go - About 50 mins to fix

                      Method worker.Subscribe has 8 return statements (exceeds 4 allowed).
                      Open

                      func (w *worker) Subscribe(ctx context.Context, subscription *api.SubscriptionMessage) error {
                          log.G(ctx).Debugf("Received subscription %s (selector: %v)", subscription.ID, subscription.Selector)
                      
                          publisher, cancel, err := w.publisherProvider.Publisher(ctx, subscription.ID)
                          if err != nil {
                      Severity: Major
                      Found in agent/worker.go - About 50 mins to fix

                        Function processIPAMOptions has 8 return statements (exceeds 4 allowed).
                        Open

                        func processIPAMOptions(cmd *cobra.Command) (*api.IPAMOptions, error) {
                            flags := cmd.Flags()
                        
                            var ipamOpts *api.IPAMOptions
                            if flags.Changed("ipam-driver") {
                        Severity: Major
                        Found in swarmd/cmd/swarmctl/network/create.go - About 50 mins to fix

                          Function reconcileTaskState has 8 return statements (exceeds 4 allowed).
                          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 50 mins to fix

                            Method Resolver.get has 8 return statements (exceeds 4 allowed).
                            Open

                            func (r *Resolver) get(t interface{}, id string) string {
                                switch t.(type) {
                                case api.Node:
                                    res, err := r.c.GetNode(r.ctx, &api.GetNodeRequest{NodeID: id})
                                    if err != nil {
                            Severity: Major
                            Found in swarmd/cmd/swarmctl/common/resolver.go - About 50 mins to fix

                              Method controller.Prepare has 8 return statements (exceeds 4 allowed).
                              Open

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

                                Function ConvertResourceWatch has 8 return statements (exceeds 4 allowed).
                                Open

                                func ConvertResourceWatch(action WatchActionKind, filters []*SelectBy, kind string) ([]Event, error) {
                                    var (
                                        m          Resource
                                        checkFuncs []ResourceCheckFunc
                                    )
                                Severity: Major
                                Found in api/objects.pb.go - About 50 mins to fix

                                  Function ConvertSecretWatch has 8 return statements (exceeds 4 allowed).
                                  Open

                                  func ConvertSecretWatch(action WatchActionKind, filters []*SelectBy) ([]Event, error) {
                                      var (
                                          m          Secret
                                          checkFuncs []SecretCheckFunc
                                      )
                                  Severity: Major
                                  Found in api/objects.pb.go - About 50 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language