kubenetworks/kubevpn

View on GitHub

Showing 526 of 526 total issues

Method Manager.updateDHCPConfigMap has 56 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (m *Manager) updateDHCPConfigMap(ctx context.Context, f func(ipv4 *ipallocator.Range, ipv6 *ipallocator.Range) error) error {
    cm, err := m.client.Get(ctx, config.ConfigMapPodTrafficManager, metav1.GetOptions{})
    if err != nil {
        return fmt.Errorf("failed to get configmap DHCP server, err: %v", err)
    }
Severity: Minor
Found in pkg/dhcp/dhcp.go - About 1 hr to fix

    Function Complete has 55 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func Complete(ctx context.Context, route *core.Route) error {
        if v, ok := os.LookupEnv(config.EnvInboundPodTunIPv4); !ok || v != "" {
            return nil
        }
    
    
    Severity: Minor
    Found in pkg/handler/tools.go - About 1 hr to fix

      Function TCPForwarder has 55 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func TCPForwarder(s *stack.Stack) func(stack.TransportEndpointID, *stack.PacketBuffer) bool {
          GvisorTCPForwardAddr := GvisorTCPForwardAddr
          return tcp.NewForwarder(s, 0, 100000, func(request *tcp.ForwarderRequest) {
              defer request.Complete(false)
              id := request.ID()
      Severity: Minor
      Found in pkg/core/gvisortcpforwarder.go - About 1 hr to fix

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

        func printDisconnectResp(disconnect rpc.Daemon_DisconnectClient) error {
            for {
                recv, err := disconnect.Recv()
                if err == io.EOF {
                    return nil
        Severity: Major
        Found in cmd/kubevpn/cmds/reset.go and 1 other location - About 1 hr to fix
        cmd/kubevpn/cmds/reset.go on lines 95..107

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

        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 printResetResp(resp rpc.Daemon_ResetClient) error {
            for {
                recv, err := resp.Recv()
                if err == io.EOF {
                    return nil
        Severity: Major
        Found in cmd/kubevpn/cmds/reset.go and 1 other location - About 1 hr to fix
        cmd/kubevpn/cmds/reset.go on lines 109..121

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

        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 ConnectOptions.addExtraRoute has 12 return statements (exceeds 4 allowed).
        Open

        func (c *ConnectOptions) addExtraRoute(ctx context.Context, nameserver string) error {
            if len(c.ExtraRouteInfo.ExtraDomain) == 0 {
                return nil
            }
        
        
        Severity: Major
        Found in pkg/handler/connect.go - About 1 hr to fix

          Method Options.Connect has 12 return statements (exceeds 4 allowed).
          Open

          func (option *Options) Connect(ctx context.Context, sshConfig *pkgssh.SshConfig, transferImage bool, portBindings nat.PortMap) error {
              switch option.ConnectMode {
              case ConnectModeHost:
                  daemonCli := daemon.GetClient(false)
                  if daemonCli == nil {
          Severity: Major
          Found in pkg/dev/options.go - About 1 hr to fix

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

                for _, address := range cred.Addresses {
                    // Type
                    err = binary.Write(b, *endian, uint16(address.AddrType))
                    if err != nil {
                        return []byte{}, err
            Severity: Major
            Found in pkg/ssh/gssapi_ccache.go and 1 other location - About 1 hr to fix
            pkg/ssh/gssapi_ccache.go on lines 393..409

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

            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

                for _, authData := range cred.AuthData {
                    // Type
                    err = binary.Write(b, *endian, uint16(authData.ADType))
                    if err != nil {
                        return []byte{}, err
            Severity: Major
            Found in pkg/ssh/gssapi_ccache.go and 1 other location - About 1 hr to fix
            pkg/ssh/gssapi_ccache.go on lines 367..383

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

            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

                go func() {
                    buf := config.LPool.Get().([]byte)[:]
                    defer config.LPool.Put(buf[:])
                    _, err := io.CopyBuffer(local, remote, buf)
                    if err != nil && !errors.Is(err, net.ErrClosed) && !errors.Is(err, io.EOF) {
            Severity: Major
            Found in pkg/ssh/ssh.go and 1 other location - About 1 hr to fix
            pkg/ssh/ssh.go on lines 273..284

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

            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

                go func() {
                    buf := config.LPool.Get().([]byte)[:]
                    defer config.LPool.Put(buf[:])
                    _, err := io.CopyBuffer(remote, local, buf)
                    if err != nil && !errors.Is(err, net.ErrClosed) && !errors.Is(err, io.EOF) {
            Severity: Major
            Found in pkg/ssh/ssh.go and 1 other location - About 1 hr to fix
            pkg/ssh/ssh.go on lines 259..270

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

            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 ConnectOptions.PreCheckResource has 54 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (c *ConnectOptions) PreCheckResource() error {
                if len(c.Workloads) == 0 {
                    return nil
                }
            
            
            Severity: Minor
            Found in pkg/handler/connect.go - About 1 hr to fix

              Method SvrOption.detectUnixSocksFile has 53 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (o *SvrOption) detectUnixSocksFile(ctx context.Context) {
                  var f = func() {
                      _, err := os.Stat(config.GetSockPath(o.IsSudo))
                      if errors.Is(err, os.ErrNotExist) {
                          o.Stop()
              Severity: Minor
              Found in pkg/daemon/daemon.go - About 1 hr to fix

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

                    configFlags.WrapConfigFn = func(c *rest.Config) *rest.Config {
                        if path, ok := os.LookupEnv(config.EnvSSHJump); ok {
                            kubeconfigBytes, err := os.ReadFile(path)
                            cmdutil.CheckErr(err)
                            var conf *restclient.Config
                Severity: Major
                Found in cmd/kubevpn/cmds/root.go and 1 other location - About 1 hr to fix
                pkg/util/ns.go on lines 149..159

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

                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

                    configFlags.WrapConfigFn = func(c *rest.Config) *rest.Config {
                        if path, ok := os.LookupEnv(config.EnvSSHJump); ok {
                            bytes, err := os.ReadFile(path)
                            cmdutil.CheckErr(err)
                            var conf *rest.Config
                Severity: Major
                Found in pkg/util/ns.go and 1 other location - About 1 hr to fix
                cmd/kubevpn/cmds/root.go on lines 35..45

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

                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

                type UploaderEntity struct {
                    Login             string `json:"login"`
                    Id                int64  `json:"id"`
                    NodeId            string `json:"node_id"`
                    AvatarUrl         string `json:"avatar_url"`
                Severity: Major
                Found in pkg/util/upgrade.go and 1 other location - About 1 hr to fix
                pkg/util/upgrade.go on lines 180..199

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

                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

                type AuthorEntity struct {
                    Login             string `json:"login"`
                    Id                int64  `json:"id"`
                    NodeId            string `json:"node_id"`
                    AvatarUrl         string `json:"avatar_url"`
                Severity: Major
                Found in pkg/util/upgrade.go and 1 other location - About 1 hr to fix
                pkg/util/upgrade.go on lines 217..236

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

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

                func CmdGet(f cmdutil.Factory) *cobra.Command {
                    var printFlags = cmdget.NewGetPrintFlags()
                    cmd := &cobra.Command{
                        Use:    "get",
                        Hidden: true,
                Severity: Major
                Found in cmd/kubevpn/cmds/get.go - About 1 hr to fix

                  Function createTun has 11 return statements (exceeds 4 allowed).
                  Open

                  func createTun(cfg Config) (conn net.Conn, itf *net.Interface, err error) {
                      if cfg.Addr == "" && cfg.Addr6 == "" {
                          err = fmt.Errorf("IPv4 address and IPv6 address can not be empty at same time")
                          return
                      }
                  Severity: Major
                  Found in pkg/tun/tun_bsd.go - About 1 hr to fix

                    Method wsHandler.handle has 11 return statements (exceeds 4 allowed).
                    Open

                    func (w *wsHandler) handle(c context.Context) {
                        ctx, f := context.WithCancel(c)
                        defer f()
                    
                        cli, err := pkgssh.DialSshRemote(ctx, w.sshConfig, ctx.Done())
                    Severity: Major
                    Found in pkg/daemon/handler/ssh.go - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language