docker/swarmkit

View on GitHub

Showing 1,008 of 1,820 total issues

Method ProcessRaftMessageResponse.Unmarshal has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
Open

func (m *ProcessRaftMessageResponse) Unmarshal(dAtA []byte) error {
    l := len(dAtA)
    iNdEx := 0
    for iNdEx < l {
        preIndex := iNdEx
Severity: Minor
Found in api/raft.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 InternalRaftRequest.Unmarshal has 19 return statements (exceeds 4 allowed).
Open

func (m *InternalRaftRequest) 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 test.Generate has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
    Open

    func (p *test) Generate(imports generator.PluginImports, file *generator.FileDescriptor) bool {
        used := false
        testingPkg := imports.NewImport("testing")
        randPkg := imports.NewImport("math/rand")
        timePkg := imports.NewImport("time")
    Severity: Minor
    Found in protobuf/plugin/deepcopy/deepcopytest.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 watchNetwork has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
    Open

    func watchNetwork(t *testing.T, watch chan events.Event, expectTimeout bool, fn func(t assert.TestingT, n *api.Network) bool) {
        for {
            var network *api.Network
            select {
            case event := <-watch:
    Severity: Minor
    Found in manager/allocator/allocator_test_suite.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 watchTask has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
    Open

    func watchTask(t *testing.T, s *store.MemoryStore, watch chan events.Event, expectTimeout bool, fn func(t assert.TestingT, s *store.MemoryStore, n *api.Task) bool) {
        for {
            var task *api.Task
            select {
            case event := <-watch:
    Severity: Minor
    Found in manager/allocator/allocator_test_suite.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 watchService has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
    Open

    func watchService(t *testing.T, watch chan events.Event, expectTimeout bool, fn func(t assert.TestingT, n *api.Service) bool) {
        for {
            var service *api.Service
            select {
            case event := <-watch:
    Severity: Minor
    Found in manager/allocator/allocator_test_suite.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 watchNode has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
    Open

    func watchNode(t *testing.T, watch chan events.Event, expectTimeout bool,
        fn func(t assert.TestingT, originalNode, updatedNode *api.Node, networks []string) bool,
        originalNode *api.Node,
        networks []string) {
        for {
    Severity: Minor
    Found in manager/allocator/allocator_test_suite.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 Dispatcher.Run has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
    Open

    func (d *Dispatcher) Run(ctx context.Context) error {
        ctx = log.WithModule(ctx, "dispatcher")
        log.G(ctx).Info("dispatcher starting")
    
        d.taskUpdatesLock.Lock()
    Severity: Minor
    Found in manager/dispatcher/dispatcher.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 worker.Subscribe has 68 lines of code (exceeds 50 allowed). Consider refactoring.
    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: Minor
    Found in agent/worker.go - About 1 hr to fix

      Method Volume.MarshalToSizedBuffer has 68 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (m *Volume) 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 Task.Size has 68 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (m *Task) Size() (n int) {
            if m == nil {
                return 0
            }
            var l int
        Severity: Minor
        Found in api/objects.pb.go - About 1 hr to fix

          Method Supervisor.Restart has 68 lines of code (exceeds 50 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

            Method roleManager.Run has 68 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (rm *roleManager) Run(ctx context.Context) {
                defer close(rm.doneChan)
            
                var (
                    nodes []*api.Node
            Severity: Minor
            Found in manager/role_manager.go - About 1 hr to fix

              Method StoreSnapshot.String has 67 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (this *StoreSnapshot) String() string {
                  if this == nil {
                      return "nil"
                  }
                  repeatedStringForNodes := "[]*Node{"
              Severity: Minor
              Found in api/snapshot.pb.go - About 1 hr to fix

                Method deepCopyGen.genMsgDeepCopy has 67 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (d *deepCopyGen) genMsgDeepCopy(m *generator.Descriptor) {
                    ccTypeName := generator.CamelCaseSlice(m.TypeName())
                
                    // Generate backwards compatible, type-safe Copy() function.
                    d.P("func (m *", ccTypeName, ") Copy() *", ccTypeName, "{")
                Severity: Minor
                Found in protobuf/plugin/deepcopy/deepcopy.go - About 1 hr to fix

                  Function Merge has 18 return statements (exceeds 4 allowed).
                  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: Major
                  Found in swarmd/cmd/swarmctl/service/flagparser/flags.go - About 1 hr to fix

                    Method IssueNodeCertificateResponse.Unmarshal has 18 return statements (exceeds 4 allowed).
                    Open

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

                      Method UpdateVolumeStatusRequest_VolumeStatusUpdate.Unmarshal has 18 return statements (exceeds 4 allowed).
                      Open

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

                        Method SelectBySlot.Unmarshal has 18 return statements (exceeds 4 allowed).
                        Open

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

                          Method ResourceReference.Unmarshal has 18 return statements (exceeds 4 allowed).
                          Open

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