alibaba/kt-connect

View on GitHub

Showing 109 of 109 total issues

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

func getPodIps(k kubernetes.Interface, namespace string) []string {
    podList, err := k.CoreV1().Pods("").List(context.TODO(), metav1.ListOptions{
        Limit:          1000,
        TimeoutSeconds: &apiTimeout,
    })
Severity: Major
Found in pkg/kt/service/cluster/cidr.go and 1 other location - About 3 hrs to fix
pkg/kt/service/cluster/cidr.go on lines 191..215

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

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 getServiceIps(k kubernetes.Interface, namespace string) []string {
    serviceList, err := k.CoreV1().Services("").List(context.TODO(), metav1.ListOptions{
        Limit:          1000,
        TimeoutSeconds: &apiTimeout,
    })
Severity: Major
Found in pkg/kt/service/cluster/cidr.go and 1 other location - About 3 hrs to fix
pkg/kt/service/cluster/cidr.go on lines 165..189

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

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 NewMeshCommand() *cobra.Command {
    cmd := &cobra.Command{
        Use:  "mesh",
        Short: "Redirect marked requests of specified kubernetes service to local",
        PreRunE: func(cmd *cobra.Command, args []string) error {
Severity: Major
Found in pkg/kt/command/mesh.go and 2 other locations - About 3 hrs to fix
pkg/kt/command/exchange.go on lines 15..36
pkg/kt/command/preview.go on lines 16..37

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

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 NewExchangeCommand() *cobra.Command {
    cmd := &cobra.Command{
        Use:  "exchange",
        Short: "Redirect all requests of specified kubernetes service to local",
        PreRunE: func(cmd *cobra.Command, args []string) error {
Severity: Major
Found in pkg/kt/command/exchange.go and 2 other locations - About 3 hrs to fix
pkg/kt/command/mesh.go on lines 15..36
pkg/kt/command/preview.go on lines 16..37

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

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 NewPreviewCommand() *cobra.Command {
    cmd := &cobra.Command{
        Use:   "preview",
        Short: "Expose a local service to kubernetes cluster",
        PreRunE: func(cmd *cobra.Command, args []string) error {
Severity: Major
Found in pkg/kt/command/preview.go and 2 other locations - About 3 hrs to fix
pkg/kt/command/exchange.go on lines 15..36
pkg/kt/command/mesh.go on lines 15..36

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

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

Function cleanShadowPodAndConfigMap has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
Open

func cleanShadowPodAndConfigMap() {
    var err error
    if opt.Store.Shadow != "" {
        shouldDelWithShared := false
        if opt.Get().Connect.ShareShadow {
Severity: Minor
Found in pkg/kt/command/general/teardown.go - About 3 hrs 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 GlobalFlags has 100 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func GlobalFlags() []OptionConfig {
    flags := []OptionConfig{
        {
            Target:       "Namespace",
            Alias:        "n",
Severity: Major
Found in pkg/kt/command/options/global.go - About 3 hrs to fix

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

    func (k *Kubernetes) UpdateDeploymentHeartBeat(name, namespace string) {
        key := "deployment_" + name
        if _, err := k.Clientset.AppsV1().Deployments(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/deployment.go and 3 other locations - About 2 hrs to fix
    pkg/kt/service/cluster/configmap.go on lines 34..48
    pkg/kt/service/cluster/pod.go on lines 75..89
    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 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 4 locations. Consider refactoring.
    Open

    func (k *Kubernetes) UpdateServiceHeartBeat(name, namespace string) {
        key := "service_" + name
        if _, err := k.Clientset.CoreV1().Services(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/service.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/pod.go on lines 75..89

    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 4 locations. Consider refactoring.
    Open

    func (k *Kubernetes) UpdateConfigMapHeartBeat(name, namespace string) {
        key := "configmap_" + name
        if _, err := k.Clientset.CoreV1().ConfigMaps(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/configmap.go and 3 other locations - About 2 hrs to fix
    pkg/kt/service/cluster/deployment.go on lines 88..102
    pkg/kt/service/cluster/pod.go on lines 75..89
    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 NewCleanCommand() *cobra.Command {
        cmd := &cobra.Command{
            Use:  "clean",
            Short: "Delete unavailing resources created by kt from kubernetes cluster",
            PreRunE: func(cmd *cobra.Command, args []string) error {
    Severity: Major
    Found in pkg/kt/command/clean.go and 1 other location - About 2 hrs to fix
    pkg/kt/command/birdseye.go on lines 15..34

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

    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 NewBirdseyeCommand() *cobra.Command {
        cmd := &cobra.Command{
            Use:   "birdseye",
            Short: "Show summary of services status in cluster",
            PreRunE: func(cmd *cobra.Command, args []string) error {
    Severity: Major
    Found in pkg/kt/command/birdseye.go and 1 other location - About 2 hrs to fix
    pkg/kt/command/clean.go on lines 14..33

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

    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

    Function ConnectFlags has 86 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func ConnectFlags() []OptionConfig {
        flags := []OptionConfig{
            {
                Target:      "Mode",
                DefaultValue: util.ConnectModeTun2Socks,
    Severity: Major
    Found in pkg/kt/command/options/connect.go - About 2 hrs to fix

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

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

      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) 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

      Function UpdateServiceSelector has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
      Open

      func UpdateServiceSelector(svcName, namespace string, selector map[string]string) error {
          svc, err := cluster.Ins().GetService(svcName, namespace)
          if err != nil {
              return err
          }
      Severity: Minor
      Found in pkg/kt/command/general/resource.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 mergeOptions has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
      Open

      func mergeOptions(opt *DaemonOptions, data []byte) {
          config := make(map[string]map[string]string)
          err := yaml.Unmarshal(data, &config)
          if err != nil {
              log.Warn().Msgf("Invalid config content, skipping ...")
      Severity: Minor
      Found in pkg/kt/command/options/options.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 Kubernetes.ClusterCidr has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
      Open

      func (k *Kubernetes) ClusterCidr(namespace string) ([]string, []string) {
          ips := getServiceIps(k.Clientset, namespace)
          log.Debug().Msgf("Found %d IPs", len(ips))
          svcCidr := calculateMinimalIpRange(ips)
          log.Debug().Msgf("Service ips are: %v", ips)
      Severity: Minor
      Found in pkg/kt/service/cluster/cidr.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 getServiceHosts has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
      Open

      func getServiceHosts(namespace string, shortDomainOnly bool) (map[string]string, []string) {
          hosts := make(map[string]string)
          podNames := make([]string, 0)
          services, err := cluster.Ins().GetAllServiceInNamespace(namespace)
          if err == nil {
      Severity: Minor
      Found in pkg/kt/command/connect/common.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

      Severity
      Category
      Status
      Source
      Language