kubenetworks/kubevpn

View on GitHub

Showing 526 of 526 total issues

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

            for {
                resp, err = client.Recv()
                if err == io.EOF {
                    break
                } else if err == nil {
Severity: Minor
Found in cmd/kubevpn/cmds/proxy.go and 1 other location - About 45 mins to fix
cmd/kubevpn/cmds/quit.go on lines 53..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 115.

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 GvisorTCPListener(addr string) (net.Listener, error) {
    log.Debugf("Gvisor tcp listen addr %s", addr)
    laddr, err := net.ResolveTCPAddr("tcp", addr)
    if err != nil {
        return nil, err
Severity: Minor
Found in pkg/core/gvisortcphandler.go and 1 other location - About 45 mins to fix
pkg/core/gvisorudphandler.go on lines 118..129

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

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

    if cfg.Addr != "" {
        if ipv4, _, err = net.ParseCIDR(cfg.Addr); err != nil {
            return
        }
        var prefix netip.Prefix
Severity: Minor
Found in pkg/tun/tun_windows.go and 1 other location - About 45 mins to fix
pkg/tun/tun_windows.go on lines 54..65

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

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

    if cfg.Addr6 != "" {
        if ipv6, _, err = net.ParseCIDR(cfg.Addr6); err != nil {
            return
        }
        var prefix netip.Prefix
Severity: Minor
Found in pkg/tun/tun_windows.go and 1 other location - About 45 mins to fix
pkg/tun/tun_windows.go on lines 41..52

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

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 GvisorUDPListener(addr string) (net.Listener, error) {
    log.Debugf("Gvisor UDP over TCP listen addr %s", addr)
    laddr, err := net.ResolveTCPAddr("tcp", addr)
    if err != nil {
        return nil, err
Severity: Minor
Found in pkg/core/gvisorudphandler.go and 1 other location - About 45 mins to fix
pkg/core/gvisortcphandler.go on lines 91..102

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

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

    do := f.NewBuilder().
        Unstructured().
        NamespaceParam(ns).DefaultNamespace().AllNamespaces(false).
        ResourceTypeOrNameArgs(true, workloads...).
        ContinueOnError().
Severity: Minor
Found in pkg/util/unstructure.go and 1 other location - About 40 mins to fix
pkg/util/unstructure.go on lines 16..24

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

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

    do := f.NewBuilder().
        Unstructured().
        NamespaceParam(ns).DefaultNamespace().AllNamespaces(false).
        ResourceTypeOrNameArgs(true, workloads).
        ContinueOnError().
Severity: Minor
Found in pkg/util/unstructure.go and 1 other location - About 40 mins to fix
pkg/util/unstructure.go on lines 39..47

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

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.InitClient has 6 return statements (exceeds 4 allowed).
Open

func (d *CloneOptions) InitClient(f cmdutil.Factory) (err error) {
    d.factory = f
    if d.config, err = d.factory.ToRESTConfig(); err != nil {
        return
    }
Severity: Major
Found in pkg/handler/clone.go - About 40 mins to fix

    Method CloneOptions.setVolume has 6 return statements (exceeds 4 allowed).
    Open

    func (d *CloneOptions) setVolume(u *unstructured.Unstructured) error {
    
        const TokenVolumeMountPath = "/var/run/secrets/kubernetes.io/serviceaccount"
    
        type VolumeMountContainerPair struct {
    Severity: Major
    Found in pkg/handler/clone.go - About 40 mins to fix

      Function GetManifest has 6 return statements (exceeds 4 allowed).
      Open

      func GetManifest(httpCli *http.Client, os string, arch string) (version string, url string, err error) {
          var resp *http.Response
          var errs []error
          for _, a := range address {
              resp, err = httpCli.Get(a)
      Severity: Major
      Found in pkg/util/upgrade.go - About 40 mins to fix

        Function CmdRemove has 6 return statements (exceeds 4 allowed).
        Open

        func CmdRemove(f cmdutil.Factory) *cobra.Command {
            var cmd = &cobra.Command{
                Use:   "remove",
                Short: "Remove clone resource",
                Long: templates.LongDesc(i18n.T(`
        Severity: Major
        Found in cmd/kubevpn/cmds/remove.go - About 40 mins to fix

          Function UnzipKubeVPNIntoFile has 6 return statements (exceeds 4 allowed).
          Open

          func UnzipKubeVPNIntoFile(zipFile, filename string) error {
              archive, err := zip.OpenReader(zipFile)
              if err != nil {
                  return err
              }
          Severity: Major
          Found in pkg/util/upgrade.go - About 40 mins to fix

            Function CmdDaemon has 6 return statements (exceeds 4 allowed).
            Open

            func CmdDaemon(_ cmdutil.Factory) *cobra.Command {
                var opt = &daemon.SvrOption{}
                cmd := &cobra.Command{
                    Use:   "daemon",
                    Short: i18n.T("Startup kubevpn daemon server"),
            Severity: Major
            Found in cmd/kubevpn/cmds/daemon.go - About 40 mins to fix

              Method ConnectOptions.portForward has 6 return statements (exceeds 4 allowed).
              Open

              func (c *ConnectOptions) portForward(ctx context.Context, portPair []string) error {
                  firstCtx, firstCancelFunc := context.WithCancel(ctx)
                  defer firstCancelFunc()
                  var errChan = make(chan error, 1)
                  go func() {
              Severity: Major
              Found in pkg/handler/connect.go - About 40 mins to fix

                Function CmdLeave has 6 return statements (exceeds 4 allowed).
                Open

                func CmdLeave(f cmdutil.Factory) *cobra.Command {
                    var leaveCmd = &cobra.Command{
                        Use:   "leave",
                        Short: i18n.T("Leave proxy resource"),
                        Long: templates.LongDesc(i18n.T(`
                Severity: Major
                Found in cmd/kubevpn/cmds/leave.go - About 40 mins to fix

                  Function CmdLogs has 6 return statements (exceeds 4 allowed).
                  Open

                  func CmdLogs(f cmdutil.Factory) *cobra.Command {
                      req := &rpc.LogRequest{}
                      cmd := &cobra.Command{
                          Use:   "logs",
                          Short: i18n.T("Log kubevpn daemon grpc server"),
                  Severity: Major
                  Found in cmd/kubevpn/cmds/logs.go - About 40 mins to fix

                    Function DownloadFileWithName has 6 return statements (exceeds 4 allowed).
                    Open

                    func DownloadFileWithName(uri, name string) (string, error) {
                        resp, err := getWithRetry(uri)
                        if err != nil {
                            return "", err
                        }
                    Severity: Major
                    Found in pkg/util/krew/sha256.go - About 40 mins to fix

                      Function CmdAlias has 6 return statements (exceeds 4 allowed).
                      Open

                      func CmdAlias(f cmdutil.Factory) *cobra.Command {
                          var localFile, remoteAddr string
                          cmd := &cobra.Command{
                              Use:   "alias",
                              Short: i18n.T("Config file alias to execute command simply"),
                      Severity: Major
                      Found in cmd/kubevpn/cmds/alias.go - About 40 mins to fix

                        Method ConnectOptions.GetIPFromContext has 6 return statements (exceeds 4 allowed).
                        Open

                        func (c *ConnectOptions) GetIPFromContext(ctx context.Context) error {
                            md, ok := metadata.FromIncomingContext(ctx)
                            if !ok {
                                return fmt.Errorf("can not get IOP from context")
                            }
                        Severity: Major
                        Found in pkg/handler/connect.go - About 40 mins to fix

                          Method ConnectOptions.startLocalTunServe has 6 return statements (exceeds 4 allowed).
                          Open

                          func (c *ConnectOptions) startLocalTunServe(ctx context.Context, forwardAddress string, lite bool) (err error) {
                              log.Debugf("IPv4: %s, IPv6: %s", c.localTunIPv4.IP.String(), c.localTunIPv6.IP.String())
                          
                              var cidrList []*net.IPNet
                              if !lite {
                          Severity: Major
                          Found in pkg/handler/connect.go - About 40 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language