kubenetworks/kubevpn

View on GitHub

Showing 358 of 556 total issues

Method admissionReviewHandler.handleDelete has 5 return statements (exceeds 4 allowed).
Open

func (h *admissionReviewHandler) handleDelete(ar v1.AdmissionReview) *v1.AdmissionResponse {
    raw := ar.Request.OldObject.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 35 mins to fix

    Method Server.Reset has 5 return statements (exceeds 4 allowed).
    Open

    func (svr *Server) Reset(req *rpc.ResetRequest, resp rpc.Daemon_ResetServer) error {
        defer func() {
            log.SetOutput(svr.LogFile)
            log.SetLevel(log.DebugLevel)
        }()
    Severity: Major
    Found in pkg/daemon/action/reset.go - About 35 mins to fix

      Function CreateFolder has 5 return statements (exceeds 4 allowed).
      Open

      func CreateFolder(ctx context.Context, cli *client.Client, id string, src string, target string) (string, error) {
          lstat, err := os.Lstat(src)
          if err != nil {
              return "", err
          }
      Severity: Major
      Found in pkg/util/volume.go - About 35 mins to fix

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

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

          Function init has 5 return statements (exceeds 4 allowed).
          Open

          func init() {
              http.Handle("/ws", websocket.Handler(func(conn *websocket.Conn) {
                  sshConfig := util.SshConfig{
                      Addr:             conn.Request().Header.Get("ssh-addr"),
                      User:             conn.Request().Header.Get("ssh-username"),
          Severity: Major
          Found in pkg/daemon/handler/ssh.go - About 35 mins to fix

            Function CopyVolumeIntoContainer has 5 return statements (exceeds 4 allowed).
            Open

            func CopyVolumeIntoContainer(ctx context.Context, volume []mount.Mount, cli *client.Client, id string) error {
                // copy volume into container
                for _, v := range volume {
                    target, err := CreateFolder(ctx, cli, id, v.Source, v.Target)
                    if err != nil {
            Severity: Major
            Found in pkg/util/volume.go - About 35 mins to fix

              Function heartbeats has 5 return statements (exceeds 4 allowed).
              Open

              func heartbeats(ctx context.Context, tun net.Conn, in chan<- *DataElem) {
                  conn, err := util.GetTunDeviceByConn(tun)
                  if err != nil {
                      log.Errorf("get tun device error: %s", err.Error())
                      return
              Severity: Major
              Found in pkg/core/tunhandler.go - About 35 mins to fix

                Method tcpKeepAliveListener.Accept has 5 return statements (exceeds 4 allowed).
                Open

                func (ln *tcpKeepAliveListener) Accept() (c net.Conn, err error) {
                    conn, err := ln.AcceptTCP()
                    if err != nil {
                        return
                    }
                Severity: Major
                Found in pkg/core/tcp.go - About 35 mins to fix

                  Function GetClientWithoutCache has 5 return statements (exceeds 4 allowed).
                  Open

                  func GetClientWithoutCache(ctx context.Context, isSudo bool) (cli rpc.DaemonClient, conn *grpc.ClientConn, err error) {
                      sockPath := GetSockPath(isSudo)
                      _, err = os.Stat(sockPath)
                      if errors.Is(err, os.ErrNotExist) {
                          return
                  Severity: Major
                  Found in pkg/daemon/client.go - About 35 mins to fix

                    Method SvrOption.detectUnixSocksFile has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (o *SvrOption) detectUnixSocksFile(ctx context.Context) {
                        var f = func() {
                            _, err := os.Stat(GetSockPath(o.IsSudo))
                            if errors.Is(err, os.ErrNotExist) {
                                o.Stop()
                    Severity: Minor
                    Found in pkg/daemon/daemon.go - About 35 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 Server.List has 5 return statements (exceeds 4 allowed).
                    Open

                    func (svr *Server) List(ctx context.Context, req *rpc.ListRequest) (*rpc.ListResponse, error) {
                        if svr.connect == nil || svr.connect.GetClientset() == nil {
                            return nil, fmt.Errorf("not connect to any cluster")
                        }
                        mapInterface := svr.connect.GetClientset().CoreV1().ConfigMaps(svr.connect.Namespace)
                    Severity: Major
                    Found in pkg/daemon/action/list.go - About 35 mins to fix

                      Function runDaemon has 5 return statements (exceeds 4 allowed).
                      Open

                      func runDaemon(ctx context.Context, exe string, isSudo bool) error {
                          cli := GetClient(isSudo)
                          if cli != nil {
                              return nil
                          }
                      Severity: Major
                      Found in pkg/daemon/client.go - About 35 mins to fix

                        Function CleanupHosts has 5 return statements (exceeds 4 allowed).
                        Open

                        func CleanupHosts() error {
                            path := GetHostFile()
                            content, err := os.ReadFile(path)
                            if err != nil {
                                return err
                        Severity: Major
                        Found in pkg/dns/dns.go - About 35 mins to fix

                          Function DialSshRemote has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func DialSshRemote(ctx context.Context, conf *SshConfig) (remote *ssh.Client, err error) {
                              defer func() {
                                  if err != nil {
                                      if remote != nil {
                                          remote.Close()
                          Severity: Minor
                          Found in pkg/util/ssh.go - About 25 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 parseSecurityOpts has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func parseSecurityOpts(securityOpts []string) ([]string, error) {
                              for key, opt := range securityOpts {
                                  k, v, ok := strings.Cut(opt, "=")
                                  if !ok && k != "no-new-privileges" {
                                      k, v, ok = strings.Cut(opt, ":")
                          Severity: Minor
                          Found in pkg/dev/docker_opts.go - About 25 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 gen has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func gen(connect *handler.ConnectOptions, clone *handler.CloneOptions) ([]*rpc.Proxy, []*rpc.Clone, error) {
                              var proxyList []*rpc.Proxy
                              if connect != nil && connect.GetClientset() != nil {
                                  mapInterface := connect.GetClientset().CoreV1().ConfigMaps(connect.Namespace)
                                  configMap, err := mapInterface.Get(context.Background(), config.ConfigMapPodTrafficManager, metav1.GetOptions{})
                          Severity: Minor
                          Found in pkg/daemon/action/status.go - About 25 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 GetClient has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func GetClient(isSudo bool) (cli rpc.DaemonClient) {
                              sockPath := GetSockPath(isSudo)
                              if _, err := os.Stat(sockPath); errors.Is(err, os.ErrNotExist) {
                                  return nil
                              }
                          Severity: Minor
                          Found in pkg/daemon/client.go - About 25 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 Config.usingNetworkSetup has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func (c *Config) usingNetworkSetup(ip string, namespace string) {
                              networkSetup(ip, namespace)
                              var ctx context.Context
                              ctx, cancel = context.WithCancel(context.Background())
                              go func() {
                          Severity: Minor
                          Found in pkg/dns/dns_unix.go - About 25 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

                          Severity
                          Category
                          Status
                          Source
                          Language