alibaba/kt-connect

View on GitHub
pkg/kt/service/cluster/pod.go

Summary

Maintainability
C
1 day
Test Coverage

Function execute has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

func execute(method string, url *url.URL, config *restclient.Config, stdin io.Reader, stdout, stderr io.Writer, tty bool) error {
Severity: Minor
Found in pkg/kt/service/cluster/pod.go - About 45 mins to fix

    Method Kubernetes.waitPodsReady has 5 return statements (exceeds 4 allowed).
    Open

    func (k *Kubernetes) waitPodsReady(labels map[string]string, namespace string, timeoutSec int, times int) ([]coreV1.Pod, error) {
        pods, err := k.GetPodsByLabel(labels, namespace)
        if err != nil {
            return nil, err
        }
    Severity: Major
    Found in pkg/kt/service/cluster/pod.go - About 35 mins to fix

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

      func (k *Kubernetes) UpdatePodHeartBeat(name, namespace string) {
          key := "pod_" + name
          if _, err := k.Clientset.CoreV1().Pods(namespace).
              Patch(context.TODO(), name, types.JSONPatchType, []byte(resourceHeartbeatPatch()), metav1.PatchOptions{}); err != nil {
              if healthy, exists := LastHeartBeatStatus.Get(key); healthy || !exists {
      Severity: Major
      Found in pkg/kt/service/cluster/pod.go and 3 other locations - About 2 hrs to fix
      pkg/kt/service/cluster/configmap.go on lines 34..48
      pkg/kt/service/cluster/deployment.go on lines 88..102
      pkg/kt/service/cluster/service.go on lines 76..90

      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 241.

      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

      func (k *Kubernetes) IncreasePodRef(name string, namespace string) error {
          pod, err := k.GetPod(name, namespace)
          if err != nil {
              return err
          }
      Severity: Major
      Found in pkg/kt/service/cluster/pod.go and 1 other location - About 2 hrs to fix
      pkg/kt/service/cluster/deployment.go on lines 48..64

      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 203.

      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

      func (k *Kubernetes) WatchPod(name, namespace string, fAdd, fDel, fMod func(*coreV1.Pod)) {
          k.watchResource(name, namespace, string(coreV1.ResourcePods), &coreV1.Pod{},
              func(obj any) {
                  handlePodEvent(obj, "added", fAdd)
              },
      Severity: Major
      Found in pkg/kt/service/cluster/pod.go and 1 other location - About 1 hr to fix
      pkg/kt/service/cluster/service.go on lines 93..105

      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 149.

      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

      func handlePodEvent(obj any, status string, f func(*coreV1.Pod)) {
          switch obj.(type) {
          case *coreV1.Pod:
              if f != nil {
                  log.Debug().Msgf("Pod %s %s", obj.(*coreV1.Pod).Name, status)
      Severity: Minor
      Found in pkg/kt/service/cluster/pod.go and 1 other location - About 50 mins to fix
      pkg/kt/service/cluster/service.go on lines 107..117

      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 119.

      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

      There are no issues that match your filters.

      Category
      Status