docker/swarmkit

View on GitHub

Showing 1,008 of 1,820 total issues

Function Merge has 73 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func Merge(cmd *cobra.Command, spec *api.ServiceSpec, c api.ControlClient) error {
    flags := cmd.Flags()

    if flags.Changed("force") {
        force, err := flags.GetBool("force")
Severity: Minor
Found in swarmd/cmd/swarmctl/service/flagparser/flags.go - About 1 hr to fix

    Method testSuite.TestAllocateServiceConflictingUserDefinedPorts has 73 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (suite *testSuite) TestAllocateServiceConflictingUserDefinedPorts() {
        s := store.NewMemoryStore(nil)
        suite.NotNil(s)
        defer s.Close()
    
    
    Severity: Minor
    Found in manager/allocator/allocator_test_suite.go - About 1 hr to fix

      Method testSuite.TestNodeAttachmentOnLeadershipChange has 73 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (suite *testSuite) TestNodeAttachmentOnLeadershipChange() {
          s := store.NewMemoryStore(nil)
          suite.NotNil(s)
          defer s.Close()
      
      
      Severity: Minor
      Found in manager/allocator/allocator_test_suite.go - About 1 hr to fix

        Function EventFromStoreAction has 21 return statements (exceeds 4 allowed).
        Open

        func EventFromStoreAction(sa StoreAction, oldObject StoreObject) (Event, error) {
            switch v := sa.Target.(type) {
            case *StoreAction_Node:
                switch sa.Action {
                case StoreActionKindCreate:
        Severity: Major
        Found in api/objects.pb.go - About 1 hr to fix

          Method Endpoint_VirtualIP.Unmarshal has 21 return statements (exceeds 4 allowed).
          Open

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

            Function WatchMessageEvent has 21 return statements (exceeds 4 allowed).
            Open

            func WatchMessageEvent(c Event) *WatchMessage_Event {
                switch v := c.(type) {
                case EventCreateNode:
                    return &WatchMessage_Event{Action: WatchActionKindCreate, Object: &Object{Object: &Object_Node{Node: v.Node}}}
                case EventUpdateNode:
            Severity: Major
            Found in api/objects.pb.go - About 1 hr to fix

              Method StoreSnapshot.CopyFrom has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
              Open

              func (m *StoreSnapshot) CopyFrom(src interface{}) {
              
                  o := src.(*StoreSnapshot)
                  *m = *o
                  if o.Nodes != nil {
              Severity: Minor
              Found in api/snapshot.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 LogAttr.Unmarshal has 21 return statements (exceeds 4 allowed).
              Open

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

                Method ContainerSpec_Ulimit.Unmarshal has 21 return statements (exceeds 4 allowed).
                Open

                func (m *ContainerSpec_Ulimit) 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

                  Method Allocator.allocateNode has a Cognitive Complexity of 30 (exceeds 20 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

                  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 MemoryStore.update has a Cognitive Complexity of 30 (exceeds 20 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

                  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 portAllocator.isPortsAllocatedOnInit has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (pa *portAllocator) isPortsAllocatedOnInit(s *api.Service, onInit bool) bool {
                      // If service has no user-defined endpoint and allocated endpoint,
                      // we assume it is allocated and return true.
                      if s.Endpoint == nil && s.Spec.Endpoint == nil {
                          return true
                  Severity: Minor
                  Found in manager/allocator/portallocator.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 StoreSnapshot.CopyFrom has 72 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

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

                    Method Supervisor.DelayStart has 72 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (r *Supervisor) DelayStart(ctx context.Context, _ store.Tx, oldTask *api.Task, newTaskID string, delay time.Duration, waitStop bool) <-chan struct{} {
                        ctx, cancel := context.WithCancel(context.Background())
                        doneCh := make(chan struct{})
                    
                        r.mu.Lock()
                    Severity: Minor
                    Found in manager/orchestrator/restart/restart.go - About 1 hr to fix

                      Method Manager.handleVolume has 72 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (vm *Manager) handleVolume(ctx context.Context, id string) error {
                          var volume *api.Volume
                          vm.store.View(func(tx store.ReadTx) {
                              volume = store.GetVolume(tx, id)
                          })
                      Severity: Minor
                      Found in manager/csi/manager.go - About 1 hr to fix

                        Method Allocator.allocateTasks has 71 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (a *Allocator) allocateTasks(ctx context.Context, existingAddressesOnly bool) error {
                            var (
                                nc             = a.netCtx
                                tasks          []*api.Task
                                allocatedTasks []*api.Task
                        Severity: Minor
                        Found in manager/allocator/network.go - About 1 hr to fix

                          Function Do has 20 return statements (exceeds 4 allowed).
                          Open

                          func Do(ctx context.Context, task *api.Task, ctlr Controller) (*api.TaskStatus, error) {
                              status := task.Status.Copy()
                          
                              // stay in the current state.
                              noop := func(errs ...error) (*api.TaskStatus, error) {
                          Severity: Major
                          Found in agent/exec/controller.go - About 1 hr to fix

                            Method Server.ListNodes has 20 return statements (exceeds 4 allowed).
                            Open

                            func (s *Server) ListNodes(ctx context.Context, request *api.ListNodesRequest) (*api.ListNodesResponse, error) {
                                var (
                                    nodes []*api.Node
                                    err   error
                                )
                            Severity: Major
                            Found in manager/controlapi/node.go - About 1 hr to fix

                              Function processIPAMOptions has 70 lines of code (exceeds 50 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

                                Function dumpSnapshot has 70 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func dumpSnapshot(swarmdir, unlockKey string, redact bool) error {
                                    _, snapshot, err := loadData(swarmdir, unlockKey)
                                    if err != nil {
                                        return err
                                    }
                                Severity: Minor
                                Found in swarmd/cmd/swarm-rafttool/dump.go - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language