docker/swarmkit

View on GitHub

Showing 1,008 of 1,820 total issues

Method Server.RemoveNode has 57 lines of code (exceeds 50 allowed). Consider refactoring.
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: Minor
Found in manager/controlapi/node.go - About 1 hr to fix

    Method Dispatcher.UpdateTaskStatus has 57 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (d *Dispatcher) UpdateTaskStatus(ctx context.Context, r *api.UpdateTaskStatusRequest) (*api.UpdateTaskStatusResponse, error) {
        d.rpcRW.RLock()
        defer d.rpcRW.RUnlock()
    
        dctx, err := d.isRunningLocked()
    Severity: Minor
    Found in manager/dispatcher/dispatcher.go - About 1 hr to fix

      Function WatchFrom has 57 lines of code (exceeds 50 allowed). Consider refactoring.
      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: Minor
      Found in manager/state/store/memory.go - About 1 hr to fix

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

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

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

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

            Method Allocator.doNetworkInit has 57 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

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

              Function processIPAMOptions has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
              Open

              func processIPAMOptions(cmd *cobra.Command) (*api.IPAMOptions, error) {
                  flags := cmd.Flags()
              
                  var ipamOpts *api.IPAMOptions
                  if flags.Changed("ipam-driver") {
              Severity: Minor
              Found in swarmd/cmd/swarmctl/network/create.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 Task.MarshalToSizedBuffer has 13 return statements (exceeds 4 allowed).
              Open

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

                Method NetworkSpec.MarshalToSizedBuffer has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                Open

                func (m *NetworkSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) {
                    i := len(dAtA)
                    _ = i
                    var l int
                    _ = l
                Severity: Minor
                Found in api/specs.pb.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 Supervisor.Restart has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                Open

                func (r *Supervisor) Restart(ctx context.Context, tx store.Tx, cluster *api.Cluster, service *api.Service, t api.Task) error {
                    // TODO(aluzzardi): This function should not depend on `service`.
                
                    // Is the old task still in the process of restarting? If so, wait for
                    // its restart delay to elapse, to avoid tight restart loops (for
                Severity: Minor
                Found in manager/orchestrator/restart/restart.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 Orchestrator.tickTasks has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                Open

                func (g *Orchestrator) tickTasks(ctx context.Context) {
                    if len(g.restartTasks) == 0 {
                        return
                    }
                    err := g.store.Batch(func(batch *store.Batch) error {
                Severity: Minor
                Found in manager/orchestrator/global/global.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 a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                Open

                func validateHealthCheck(hc *api.HealthConfig) error {
                    if hc == 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

                Method LogBroker.PublishLogs has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                Open

                func (lb *LogBroker) PublishLogs(stream api.LogBroker_PublishLogsServer) (err error) {
                    remote, err := ca.RemoteNode(stream.Context())
                    if err != nil {
                        return err
                    }
                Severity: Minor
                Found in manager/logbroker/broker.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 nodeSet.tree has 56 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (ns *nodeSet) tree(serviceID string, preferences []*api.PlacementPreference, maxAssignments int, meetsConstraints func(*NodeInfo) bool, nodeLess func(*NodeInfo, *NodeInfo) bool) decisionTree {
                    var root decisionTree
                
                    if maxAssignments == 0 {
                        return root
                Severity: Minor
                Found in manager/scheduler/nodeset.go - About 1 hr to fix

                  Method Allocator.allocateTask has 56 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (a *Allocator) allocateTask(ctx context.Context, t *api.Task) (err error) {
                      taskUpdated := false
                      nc := a.netCtx
                  
                      logger := log.G(ctx).WithField("method", "(*Allocator).allocateTask")
                  Severity: Minor
                  Found in manager/allocator/network.go - About 1 hr to fix

                    Method Server.ListServices has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (s *Server) ListServices(ctx context.Context, request *api.ListServicesRequest) (*api.ListServicesResponse, error) {
                        var (
                            services []*api.Service
                            err      error
                        )
                    Severity: Minor
                    Found in manager/controlapi/service.go - About 1 hr to fix

                      Method peer.sendProcessMessage has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (p *peer) sendProcessMessage(ctx context.Context, m raftpb.Message) error {
                          // These lines used to be in the code, but they've been removed. I'm
                          // leaving them in in a comment just in case they cause some unforeseen
                          // breakage later, to show why they were removed.
                          //
                      Severity: Minor
                      Found in manager/state/raft/transport/peer.go - About 1 hr to fix

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

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

                          Function ConvertTaskWatch has 12 return statements (exceeds 4 allowed).
                          Open

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

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

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