docker/swarmkit

View on GitHub

Showing 1,008 of 1,820 total issues

Method ResolveAddressRequest.Unmarshal has 12 return statements (exceeds 4 allowed).
Open

func (m *ResolveAddressRequest) 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 Dispatcher.processUpdates has 12 return statements (exceeds 4 allowed).
    Open

    func (d *Dispatcher) processUpdates(ctx context.Context) {
        var (
            taskUpdates        map[string]*api.TaskStatus
            nodeUpdates        map[string]nodeUpdate
            unpublishedVolumes map[string][]string
    Severity: Major
    Found in manager/dispatcher/dispatcher.go - About 1 hr to fix

      Method Dispatcher.Session has 12 return statements (exceeds 4 allowed).
      Open

      func (d *Dispatcher) Session(r *api.SessionRequest, stream api.Dispatcher_SessionServer) 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 Server.checkPortConflicts has 12 return statements (exceeds 4 allowed).
        Open

        func (s *Server) checkPortConflicts(spec *api.ServiceSpec, serviceID string) error {
            if spec.Endpoint == nil {
                return nil
            }
        
        
        Severity: Major
        Found in manager/controlapi/service.go - About 1 hr to fix

          Method Server.RemoveNode has 12 return statements (exceeds 4 allowed).
          Open

          func (s *Server) RemoveNode(ctx context.Context, request *api.RemoveNodeRequest) (*api.RemoveNodeResponse, error) {
              if request.NodeID == "" {
                  return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
              }
          
          
          Severity: Major
          Found in manager/controlapi/node.go - About 1 hr to fix

            Method Node.Join has 12 return statements (exceeds 4 allowed).
            Open

            func (n *Node) Join(ctx context.Context, req *api.JoinRequest) (*api.JoinResponse, error) {
                nodeInfo, err := ca.RemoteNode(ctx)
                if err != nil {
                    return nil, err
                }
            Severity: Major
            Found in manager/state/raft/raft.go - About 1 hr to fix

              Function ParseAddSecret has 54 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func ParseAddSecret(cmd *cobra.Command, spec *api.ServiceSpec, flagName string) error {
                  flags := cmd.Flags()
              
                  if flags.Changed(flagName) {
                      secrets, err := flags.GetStringSlice(flagName)
              Severity: Minor
              Found in swarmd/cmd/swarmctl/service/flagparser/secret.go - About 1 hr to fix

                Function ParseAddConfig has 54 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func ParseAddConfig(cmd *cobra.Command, spec *api.ServiceSpec, flagName string) error {
                    flags := cmd.Flags()
                
                    if flags.Changed(flagName) {
                        configs, err := flags.GetStringSlice(flagName)
                Severity: Minor
                Found in swarmd/cmd/swarmctl/service/flagparser/config.go - About 1 hr to fix

                  Method NetworkAttachment.MarshalToSizedBuffer has 54 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (m *NetworkAttachment) 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 Dispatcher.markNodesUnknown has 54 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (d *Dispatcher) markNodesUnknown(ctx context.Context) error {
                        log := log.G(ctx).WithField("method", "(*Dispatcher).markNodesUnknown")
                        var nodes []*api.Node
                        var err error
                        d.store.View(func(tx store.ReadTx) {
                    Severity: Minor
                    Found in manager/dispatcher/dispatcher.go - About 1 hr to fix

                      Method Allocator.allocateNode has 54 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (a *Allocator) allocateNode(ctx context.Context, node *api.Node, existingAddressesOnly bool, networks []*api.Network) bool {
                          var allocated bool
                      
                          nc := a.netCtx
                      
                      
                      Severity: Minor
                      Found in manager/allocator/network.go - About 1 hr to fix

                        Method LogMessage.MarshalToSizedBuffer has 53 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

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

                          Method TaskSpec.CopyFrom has 53 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (m *TaskSpec) CopyFrom(src interface{}) {
                          
                              o := src.(*TaskSpec)
                              *m = *o
                              if o.Resources != nil {
                          Severity: Minor
                          Found in api/specs.pb.go - About 1 hr to fix

                            Method Scheduler.scheduleNTasksOnNodes has 53 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (s *Scheduler) scheduleNTasksOnNodes(ctx context.Context, n int, taskGroup map[string]*api.Task, nodes []NodeInfo, schedulingDecisions map[string]schedulingDecision, nodeLess func(a *NodeInfo, b *NodeInfo) bool) int {
                                tasksScheduled := 0
                                failedConstraints := make(map[int]bool) // key is index in nodes slice
                                nodeIter := 0
                                nodeCount := len(nodes)
                            Severity: Minor
                            Found in manager/scheduler/scheduler.go - About 1 hr to fix

                              Method Server.ListResources has 53 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func (s *Server) ListResources(ctx context.Context, request *api.ListResourcesRequest) (*api.ListResourcesResponse, error) {
                                  var (
                                      resources     []*api.Resource
                                      respResources []*api.Resource
                                      err           error
                              Severity: Minor
                              Found in manager/controlapi/resource.go - About 1 hr to fix

                                Method Deallocator.Run has 53 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func (deallocator *Deallocator) Run(ctx context.Context) error {
                                    var (
                                        allServices []*api.Service
                                        allNetworks []*api.Network
                                    )
                                Severity: Minor
                                Found in manager/deallocator/deallocator.go - About 1 hr to fix

                                  Method Node.triggerSnapshot has 53 lines of code (exceeds 50 allowed). Consider refactoring.
                                  Open

                                  func (n *Node) triggerSnapshot(ctx context.Context, raftConfig api.RaftConfig) {
                                      snapshot := api.Snapshot{Version: api.Snapshot_V0}
                                      for _, member := range n.cluster.Members() {
                                          snapshot.Membership.Members = append(snapshot.Membership.Members,
                                              &api.RaftMember{
                                  Severity: Minor
                                  Found in manager/state/raft/storage.go - About 1 hr to fix

                                    Function init has 53 lines of code (exceeds 50 allowed). Consider refactoring.
                                    Open

                                    func init() {
                                        register(ObjectStoreConfig{
                                            Table: &memdb.TableSchema{
                                                Name: tableResource,
                                                Indexes: map[string]*memdb.IndexSchema{
                                    Severity: Minor
                                    Found in manager/state/store/resources.go - About 1 hr to fix

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

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

                                        Method executor.Describe has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
                                        Open

                                        func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) {
                                            info, err := e.client.Info(ctx)
                                            if err != nil {
                                                return nil, err
                                            }
                                        Severity: Minor
                                        Found in swarmd/dockerexec/executor.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

                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language