docker/swarmkit

View on GitHub

Showing 1,008 of 1,820 total issues

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

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

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

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

      Method raftProxyRaftServer.ProcessRaftMessage has 9 return statements (exceeds 4 allowed).
      Open

      func (p *raftProxyRaftServer) ProcessRaftMessage(ctx context.Context, r *ProcessRaftMessageRequest) (*ProcessRaftMessageResponse, 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.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

              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 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 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

                    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 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 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 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 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

                            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

                              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 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 ConvertExtensionWatch has 8 return statements (exceeds 4 allowed).
                                  Open

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