kubenetworks/kubevpn

View on GitHub

Showing 333 of 526 total issues

Method Server.redirectConnectForkToSudoDaemon has 13 return statements (exceeds 4 allowed).
Open

func (svr *Server) redirectConnectForkToSudoDaemon(req *rpc.ConnectRequest, resp rpc.Daemon_ConnectServer) (err error) {
    cli := svr.GetClient(true)
    if cli == nil {
        return fmt.Errorf("sudo daemon not start")
    }
Severity: Major
Found in pkg/daemon/action/connect-fork.go - About 1 hr to fix

    Method Server.redirectToSudoDaemon has 13 return statements (exceeds 4 allowed).
    Open

    func (svr *Server) redirectToSudoDaemon(req *rpc.ConnectRequest, resp rpc.Daemon_ConnectServer) (e error) {
        cli := svr.GetClient(true)
        if cli == nil {
            return fmt.Errorf("sudo daemon not start")
        }
    Severity: Major
    Found in pkg/daemon/action/connect.go - About 1 hr to fix

      Method Server.Proxy has 13 return statements (exceeds 4 allowed).
      Open

      func (svr *Server) Proxy(req *rpc.ConnectRequest, resp rpc.Daemon_ProxyServer) (e error) {
          defer func() {
              util.InitLoggerForServer(true)
              log.SetOutput(svr.LogFile)
              config.Debug = false
      Severity: Major
      Found in pkg/daemon/action/proxy.go - About 1 hr to fix

        Function handle has 13 return statements (exceeds 4 allowed).
        Open

        func handle(ctx context.Context, tcpConn net.Conn, udpConn *net.UDPConn) {
            defer udpConn.Close()
            log.Debugf("[TUN-UDP] %s <-> %s", tcpConn.RemoteAddr(), udpConn.LocalAddr())
            errChan := make(chan error, 2)
            go func() {
        Severity: Major
        Found in pkg/core/gvisorudphandler.go - About 1 hr to fix

          Function networkCancel has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
          Open

          func networkCancel() {
              b, err := exec.Command("networksetup", "-listallnetworkservices").CombinedOutput()
              if err != nil {
                  return
              }
          Severity: Minor
          Found in pkg/dns/dns_unix.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 downloadAndInstall has 56 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func downloadAndInstall(client *http.Client, url string) error {
              temp, err := os.CreateTemp("", "*.zip")
              if err != nil {
                  return err
              }
          Severity: Minor
          Found in pkg/upgrade/upgrade.go - About 1 hr to fix

            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

                  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

                      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

                          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

                                Function createTun has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
                                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: Minor
                                Found in pkg/tun/tun_linux.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 Server.Connect has 11 return statements (exceeds 4 allowed).
                                Open

                                func (svr *Server) Connect(req *rpc.ConnectRequest, resp rpc.Daemon_ConnectServer) (e error) {
                                    defer func() {
                                        util.InitLoggerForServer(true)
                                        log.SetOutput(svr.LogFile)
                                        config.Debug = false
                                Severity: Major
                                Found in pkg/daemon/action/connect.go - About 1 hr to fix

                                  Method admissionReviewHandler.handleCreate has 11 return statements (exceeds 4 allowed).
                                  Open

                                  func (h *admissionReviewHandler) handleCreate(ar v1.AdmissionReview) *v1.AdmissionResponse {
                                      raw := ar.Request.Object.Raw
                                      pod := corev1.Pod{}
                                      deserializer := codecs.UniversalDeserializer()
                                      if _, _, err := deserializer.Decode(raw, nil, &pod); err != nil {
                                  Severity: Major
                                  Found in pkg/webhook/pods.go - About 1 hr to fix

                                    Method Server.ConnectFork has 11 return statements (exceeds 4 allowed).
                                    Open

                                    func (svr *Server) ConnectFork(req *rpc.ConnectRequest, resp rpc.Daemon_ConnectForkServer) (err error) {
                                        defer func() {
                                            util.InitLoggerForServer(true)
                                            log.SetOutput(svr.LogFile)
                                            config.Debug = false
                                    Severity: Major
                                    Found in pkg/daemon/action/connect-fork.go - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language