docker/swarmkit

View on GitHub

Showing 1,820 of 1,820 total issues

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

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                if len(m.Hosts) > 0 {
                    for iNdEx := len(m.Hosts) - 1; iNdEx >= 0; iNdEx-- {
                        i -= len(m.Hosts[iNdEx])
                        copy(dAtA[i:], m.Hosts[iNdEx])
                        i = encodeVarintSpecs(dAtA, i, uint64(len(m.Hosts[iNdEx])))
            Severity: Major
            Found in api/specs.pb.go and 2 other locations - About 1 hr to fix
            api/specs.pb.go on lines 2867..2877
            api/specs.pb.go on lines 2878..2888

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 138.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                if len(m.CapabilityAdd) > 0 {
                    for iNdEx := len(m.CapabilityAdd) - 1; iNdEx >= 0; iNdEx-- {
                        i -= len(m.CapabilityAdd[iNdEx])
                        copy(dAtA[i:], m.CapabilityAdd[iNdEx])
                        i = encodeVarintSpecs(dAtA, i, uint64(len(m.CapabilityAdd[iNdEx])))
            Severity: Major
            Found in api/specs.pb.go and 2 other locations - About 1 hr to fix
            api/specs.pb.go on lines 2867..2877
            api/specs.pb.go on lines 3001..3011

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 138.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                if len(m.CapabilityDrop) > 0 {
                    for iNdEx := len(m.CapabilityDrop) - 1; iNdEx >= 0; iNdEx-- {
                        i -= len(m.CapabilityDrop[iNdEx])
                        copy(dAtA[i:], m.CapabilityDrop[iNdEx])
                        i = encodeVarintSpecs(dAtA, i, uint64(len(m.CapabilityDrop[iNdEx])))
            Severity: Major
            Found in api/specs.pb.go and 2 other locations - About 1 hr to fix
            api/specs.pb.go on lines 2878..2888
            api/specs.pb.go on lines 3001..3011

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 138.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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

                          Similar blocks of code found in 4 locations. Consider refactoring.
                          Open

                              if flags.Changed("cpu-limit") {
                                  if spec.Task.Resources == nil {
                                      spec.Task.Resources = &api.ResourceRequirements{}
                                  }
                                  if spec.Task.Resources.Limits == nil {
                          Severity: Major
                          Found in swarmd/cmd/swarmctl/service/flagparser/resource.go and 3 other locations - About 1 hr to fix
                          swarmd/cmd/swarmctl/service/flagparser/resource.go on lines 47..57
                          swarmd/cmd/swarmctl/service/flagparser/resource.go on lines 59..69
                          swarmd/cmd/swarmctl/service/flagparser/resource.go on lines 71..81

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 137.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 4 locations. Consider refactoring.
                          Open

                              if flags.Changed("memory-reservation") {
                                  if spec.Task.Resources == nil {
                                      spec.Task.Resources = &api.ResourceRequirements{}
                                  }
                                  if spec.Task.Resources.Reservations == nil {
                          Severity: Major
                          Found in swarmd/cmd/swarmctl/service/flagparser/resource.go and 3 other locations - About 1 hr to fix
                          swarmd/cmd/swarmctl/service/flagparser/resource.go on lines 59..69
                          swarmd/cmd/swarmctl/service/flagparser/resource.go on lines 71..81
                          swarmd/cmd/swarmctl/service/flagparser/resource.go on lines 83..93

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 137.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 4 locations. Consider refactoring.
                          Open

                              if flags.Changed("memory-limit") {
                                  if spec.Task.Resources == nil {
                                      spec.Task.Resources = &api.ResourceRequirements{}
                                  }
                                  if spec.Task.Resources.Limits == nil {
                          Severity: Major
                          Found in swarmd/cmd/swarmctl/service/flagparser/resource.go and 3 other locations - About 1 hr to fix
                          swarmd/cmd/swarmctl/service/flagparser/resource.go on lines 47..57
                          swarmd/cmd/swarmctl/service/flagparser/resource.go on lines 71..81
                          swarmd/cmd/swarmctl/service/flagparser/resource.go on lines 83..93

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 137.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                              suite.NoError(s.Update(func(tx store.Tx) error {
                                  t6 := &api.Task{
                                      ID: "testTaskID6",
                                      Status: api.TaskStatus{
                                          State: api.TaskStateNew,
                          Severity: Major
                          Found in manager/allocator/allocator_test_suite.go and 1 other location - About 1 hr to fix
                          manager/allocator/allocator_test_suite.go on lines 369..384

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 137.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 3 locations. Consider refactoring.
                          Open

                          func (m *SelectBySlot) Size() (n int) {
                              if m == nil {
                                  return 0
                              }
                              var l int
                          Severity: Major
                          Found in api/watch.pb.go and 2 other locations - About 1 hr to fix
                          api/ca.pb.go on lines 1425..1439
                          api/specs.pb.go on lines 4033..4047

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 137.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Severity
                          Category
                          Status
                          Source
                          Language