docker/swarmkit

View on GitHub

Showing 1,008 of 1,820 total issues

Method ContainerSpec.MarshalToSizedBuffer has 11 return statements (exceeds 4 allowed).
Open

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

    Function skipWatch has 11 return statements (exceeds 4 allowed).
    Open

    func skipWatch(dAtA []byte) (n int, err error) {
        l := len(dAtA)
        iNdEx := 0
        depth := 0
        for iNdEx < l {
    Severity: Major
    Found in api/watch.pb.go - About 1 hr to fix

      Function skipSpecs has 11 return statements (exceeds 4 allowed).
      Open

      func skipSpecs(dAtA []byte) (n int, err error) {
          l := len(dAtA)
          iNdEx := 0
          depth := 0
          for iNdEx < l {
      Severity: Major
      Found in api/specs.pb.go - About 1 hr to fix

        Method Updater.updateTask has 11 return statements (exceeds 4 allowed).
        Open

        func (u *Updater) updateTask(ctx context.Context, slot orchestrator.Slot, updated *api.Task, order api.UpdateConfig_UpdateOrder) error {
            // Kick off the watch before even creating the updated task. This is in order to avoid missing any event.
            taskUpdates, cancel := state.Watch(u.watchQueue, api.EventUpdateTask{
                Task:   &api.Task{ID: updated.ID},
                Checks: []api.TaskCheckFunc{api.TaskCheckID},
        Severity: Major
        Found in manager/orchestrator/update/updater.go - About 1 hr to fix

          Function skipPlugin has 11 return statements (exceeds 4 allowed).
          Open

          func skipPlugin(dAtA []byte) (n int, err error) {
              l := len(dAtA)
              iNdEx := 0
              depth := 0
              for iNdEx < l {
          Severity: Major
          Found in protobuf/plugin/plugin.pb.go - About 1 hr to fix

            Function skipRaft has 11 return statements (exceeds 4 allowed).
            Open

            func skipRaft(dAtA []byte) (n int, err error) {
                l := len(dAtA)
                iNdEx := 0
                depth := 0
                for iNdEx < l {
            Severity: Major
            Found in api/raft.pb.go - About 1 hr to fix

              Function validateConfigRefsSpec has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
              Open

              func validateConfigRefsSpec(spec api.TaskSpec) error {
                  container := spec.GetContainer()
                  if container == nil {
                      return nil
                  }
              Severity: Minor
              Found in manager/controlapi/service.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 validateHealthCheck has 11 return statements (exceeds 4 allowed).
              Open

              func validateHealthCheck(hc *api.HealthConfig) error {
                  if hc == nil {
                      return nil
                  }
              
              
              Severity: Major
              Found in manager/controlapi/service.go - About 1 hr to fix

                Method Server.UpdateCluster has a Cognitive Complexity of 25 (exceeds 20 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

                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 Node.processInternalRaftRequest has 11 return statements (exceeds 4 allowed).
                Open

                func (n *Node) processInternalRaftRequest(ctx context.Context, r *api.InternalRaftRequest, cb func()) (proto.Message, error) {
                    n.stopMu.RLock()
                    if !n.IsMember() {
                        n.stopMu.RUnlock()
                        return nil, ErrStopped
                Severity: Major
                Found in manager/state/raft/raft.go - About 1 hr to fix

                  Method LogBroker.SubscribeLogs has 52 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (lb *LogBroker) SubscribeLogs(request *api.SubscribeLogsRequest, stream api.Logs_SubscribeLogsServer) error {
                      ctx := stream.Context()
                  
                      if err := validateSelector(request.Selector); err != nil {
                          return err
                  Severity: Minor
                  Found in manager/logbroker/broker.go - About 1 hr to fix

                    Method MemoryStore.update has 52 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (s *MemoryStore) update(proposer state.Proposer, cb func(Tx) error) error {
                        defer metrics.StartTimer(updateLatencyTimer)()
                        s.updateLock.Lock()
                        memDBTx := s.memDB.Txn(true)
                    
                    
                    Severity: Minor
                    Found in manager/state/store/memory.go - About 1 hr to fix

                      Function parseRestart has 51 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func parseRestart(flags *pflag.FlagSet, spec *api.ServiceSpec) error {
                          if spec.Task.Restart == nil {
                              // set new service's restart policy as RestartOnAny
                              spec.Task.Restart = &api.RestartPolicy{
                                  Condition: api.RestartOnAny,
                      Severity: Minor
                      Found in swarmd/cmd/swarmctl/service/flagparser/restart.go - About 1 hr to fix

                        Method Agent.handleSessionMessage has 51 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (a *Agent) handleSessionMessage(ctx context.Context, message *api.SessionMessage, nti *api.NodeTLSInfo) error {
                            seen := map[api.Peer]struct{}{}
                            for _, manager := range message.Managers {
                                if manager.Peer.Addr == "" {
                                    continue
                        Severity: Minor
                        Found in agent/agent.go - About 1 hr to fix

                          Method Resource.MarshalToSizedBuffer has 51 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

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

                            Method ServiceSpec.CopyFrom has 51 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (m *ServiceSpec) CopyFrom(src interface{}) {
                            
                                o := src.(*ServiceSpec)
                                *m = *o
                                github_com_moby_swarmkit_v2_api_deepcopy.Copy(&m.Annotations, &o.Annotations)
                            Severity: Minor
                            Found in api/specs.pb.go - About 1 hr to fix

                              Method Server.ListServiceStatuses has 51 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func (s *Server) ListServiceStatuses(ctx context.Context, req *api.ListServiceStatusesRequest) (*api.ListServiceStatusesResponse, error) {
                                  resp := &api.ListServiceStatusesResponse{}
                                  if req == nil {
                                      return resp, nil
                                  }
                              Severity: Minor
                              Found in manager/controlapi/service.go - About 1 hr to fix

                                Method controller.Wait has 10 return statements (exceeds 4 allowed).
                                Open

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

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

                                  func parseContainer(flags *pflag.FlagSet, spec *api.ServiceSpec) error {
                                      if flags.Changed("image") {
                                          image, err := flags.GetString("image")
                                          if err != nil {
                                              return err
                                  Severity: Major
                                  Found in swarmd/cmd/swarmctl/service/flagparser/container.go - About 1 hr to fix

                                    Function renewCerts has 10 return statements (exceeds 4 allowed).
                                    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: Major
                                    Found in swarmd/cmd/swarm-rafttool/renewcert.go - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language