kubenetworks/kubevpn

View on GitHub

Showing 526 of 526 total issues

Function Complete has 8 return statements (exceeds 4 allowed).
Open

func Complete(ctx context.Context, route *core.Route) error {
    if v, ok := os.LookupEnv(config.EnvInboundPodTunIPv4); !ok || v != "" {
        return nil
    }

Severity: Major
Found in pkg/handler/tools.go - About 50 mins to fix

    Method Manager.ForEach has 8 return statements (exceeds 4 allowed).
    Open

    func (m *Manager) ForEach(ctx context.Context, fnv4 func(net.IP), fnv6 func(net.IP)) error {
        cm, err := m.client.Get(ctx, config.ConfigMapPodTrafficManager, metav1.GetOptions{})
        if err != nil {
            return fmt.Errorf("failed to get cm DHCP server, err: %v", err)
        }
    Severity: Major
    Found in pkg/dhcp/dhcp.go - About 50 mins to fix

      Method Options.Main has 8 return statements (exceeds 4 allowed).
      Open

      func (option *Options) Main(ctx context.Context, sshConfig *pkgssh.SshConfig, flags *pflag.FlagSet, transferImage bool) error {
          mode := typescontainer.NetworkMode(option.ContainerOptions.netMode.NetworkMode())
          if mode.IsContainer() {
              log.Infof("Network mode container is %s", mode.ConnectedContainer())
              inspect, err := option.cli.ContainerInspect(ctx, mode.ConnectedContainer())
      Severity: Major
      Found in pkg/dev/options.go - About 50 mins to fix

        Method CCache.Marshal has 8 return statements (exceeds 4 allowed).
        Open

        func (c *CCache) Marshal() ([]byte, error) {
            var b bytes.Buffer
            var err error
            endian := c.getEndian()
        
        
        Severity: Major
        Found in pkg/ssh/gssapi_ccache.go - About 50 mins to fix

          Method Route.GenerateServers has 8 return statements (exceeds 4 allowed).
          Open

          func (r *Route) GenerateServers() ([]Server, error) {
              chain, err := r.parseChain()
              if err != nil && !errors.Is(err, ErrorInvalidNode) {
                  log.Errorf("Failed to parse chain: %v", err)
                  return nil, err
          Severity: Major
          Found in pkg/core/route.go - About 50 mins to fix

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

                    Resources: corev1.ResourceRequirements{
                        Requests: map[corev1.ResourceName]resource.Quantity{
                            corev1.ResourceCPU:    resource.MustParse("128m"),
                            corev1.ResourceMemory: resource.MustParse("128Mi"),
                        },
            Severity: Major
            Found in pkg/inject/exchange.go and 4 other locations - About 50 mins to fix
            pkg/inject/controller.go on lines 104..113
            pkg/inject/controller.go on lines 145..154
            pkg/handler/clone.go on lines 300..309
            pkg/handler/clone.go on lines 350..359

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

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

                    Resources: v1.ResourceRequirements{
                        Requests: map[v1.ResourceName]resource.Quantity{
                            v1.ResourceCPU:    resource.MustParse("128m"),
                            v1.ResourceMemory: resource.MustParse("128Mi"),
                        },
            Severity: Major
            Found in pkg/inject/controller.go and 4 other locations - About 50 mins to fix
            pkg/inject/controller.go on lines 145..154
            pkg/inject/exchange.go on lines 115..124
            pkg/handler/clone.go on lines 300..309
            pkg/handler/clone.go on lines 350..359

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

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

                    Resources: v1.ResourceRequirements{
                        Requests: map[v1.ResourceName]resource.Quantity{
                            v1.ResourceCPU:    resource.MustParse("128m"),
                            v1.ResourceMemory: resource.MustParse("128Mi"),
                        },
            Severity: Major
            Found in pkg/inject/controller.go and 4 other locations - About 50 mins to fix
            pkg/inject/controller.go on lines 104..113
            pkg/inject/exchange.go on lines 115..124
            pkg/handler/clone.go on lines 300..309
            pkg/handler/clone.go on lines 350..359

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

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

                            Resources: v1.ResourceRequirements{
                                Requests: map[v1.ResourceName]resource.Quantity{
                                    v1.ResourceCPU:    resource.MustParse("500m"),
                                    v1.ResourceMemory: resource.MustParse("512Mi"),
                                },
            Severity: Major
            Found in pkg/handler/clone.go and 4 other locations - About 50 mins to fix
            pkg/inject/controller.go on lines 104..113
            pkg/inject/controller.go on lines 145..154
            pkg/inject/exchange.go on lines 115..124
            pkg/handler/clone.go on lines 300..309

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

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

                            Resources: v1.ResourceRequirements{
                                Requests: map[v1.ResourceName]resource.Quantity{
                                    v1.ResourceCPU:    resource.MustParse("1000m"),
                                    v1.ResourceMemory: resource.MustParse("1024Mi"),
                                },
            Severity: Major
            Found in pkg/handler/clone.go and 4 other locations - About 50 mins to fix
            pkg/inject/controller.go on lines 104..113
            pkg/inject/controller.go on lines 145..154
            pkg/inject/exchange.go on lines 115..124
            pkg/handler/clone.go on lines 350..359

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

            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

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

            func getWithRetry(uri string) (*http.Response, error) {
                var resp *http.Response
                var err error
            
                for i := 0; i < maxRetries; i++ {
            Severity: Minor
            Found in pkg/util/krew/http.go and 1 other location - About 50 mins to fix
            pkg/util/file.go on lines 72..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 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

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

            func GetAvailableUDPPortOrDie() (int, error) {
                address, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:0", "localhost"))
                if err != nil {
                    return 0, err
                }
            Severity: Minor
            Found in pkg/util/port.go and 1 other location - About 50 mins to fix
            pkg/util/port.go on lines 56..67

            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

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

            func getWithRetry(uri string) (*http.Response, error) {
                var resp *http.Response
                var err error
            
                for i := 0; i < maxRetries; i++ {
            Severity: Minor
            Found in pkg/util/file.go and 1 other location - About 50 mins to fix
            pkg/util/krew/http.go on lines 23..40

            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

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

            func GetAvailableTCPPortOrDie() (int, error) {
                address, err := net.ResolveTCPAddr("tcp", fmt.Sprintf("%s:0", "localhost"))
                if err != nil {
                    return 0, err
                }
            Severity: Minor
            Found in pkg/util/port.go and 1 other location - About 50 mins to fix
            pkg/util/port.go on lines 43..54

            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

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

                        if len(args) == 0 {
                            _, _ = fmt.Fprintf(os.Stdout, "You must specify the type of resource to proxy. %s\n\n", cmdutil.SuggestAPIResources("kubevpn"))
                            fullCmdName := cmd.Parent().CommandPath()
                            usageString := "Required resource not specified."
                            if len(fullCmdName) > 0 && cmdutil.IsSiblingCommandExists(cmd, "explain") {
            Severity: Minor
            Found in cmd/kubevpn/cmds/clone.go and 1 other location - About 50 mins to fix
            cmd/kubevpn/cmds/dev.go on lines 77..85

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

            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

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

                        if len(args) == 0 {
                            _, _ = fmt.Fprintf(os.Stdout, "You must specify the type of resource to proxy. %s\n\n", cmdutil.SuggestAPIResources("kubevpn"))
                            fullCmdName := cmd.Parent().CommandPath()
                            usageString := "Required resource not specified."
                            if len(fullCmdName) > 0 && cmdutil.IsSiblingCommandExists(cmd, "explain") {
            Severity: Minor
            Found in cmd/kubevpn/cmds/dev.go and 1 other location - About 50 mins to fix
            cmd/kubevpn/cmds/clone.go on lines 86..94

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

            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 CloneOptions.Cleanup has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
            Open

            func (d *CloneOptions) Cleanup(workloads ...string) error {
                if len(workloads) == 0 {
                    workloads = d.Workloads
                }
                for _, workload := range workloads {
            Severity: Minor
            Found in pkg/handler/clone.go - About 45 mins 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 Connects.Less has 7 return statements (exceeds 4 allowed).
            Open

            func (s Connects) Less(i, j int) bool {
                a := s[i]
                b := s[j]
            
                if a == nil {
            Severity: Major
            Found in pkg/handler/sort.go - About 45 mins to fix

              Function GetVolume has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
              Open

              func GetVolume(ctx context.Context, f util.Factory, ns, podName string) (map[string][]mount.Mount, error) {
                  clientSet, err := f.KubernetesClientSet()
                  if err != nil {
                      return nil, err
                  }
              Severity: Minor
              Found in pkg/util/volume.go - About 45 mins 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 attachContainer has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func attachContainer(ctx context.Context, dockerCli command.Cli, containerID string, errCh *chan error, config *container.Config, options container.AttachOptions) (func(), error) {
              Severity: Minor
              Found in pkg/dev/docker_utils.go - About 45 mins to fix
                Severity
                Category
                Status
                Source
                Language