kubenetworks/kubevpn

View on GitHub

Showing 526 of 526 total issues

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

func ParseAndGet(localFile, remoteAddr string, aliasName string) ([]Config, error) {
    var content []byte
    var err error
    var path string
    if localFile != "" {
Severity: Major
Found in cmd/kubevpn/cmds/alias.go - About 35 mins to fix

    Method ConnectOptions.InitClient has 5 return statements (exceeds 4 allowed).
    Open

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

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

      func GetAPIServerFromKubeConfigBytes(kubeconfigBytes []byte) *net.IPNet {
          kubeConfig, err := clientcmd.RESTConfigFromKubeConfig(kubeconfigBytes)
          if err != nil {
              return nil
          }
      Severity: Major
      Found in pkg/util/ns.go - About 35 mins to fix

        Function GetVolume has 5 return statements (exceeds 4 allowed).
        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: Major
        Found in pkg/util/volume.go - About 35 mins to fix

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

          func quit(ctx context.Context, isSudo bool) error {
              cli := daemon.GetClient(isSudo)
              if cli == nil {
                  return nil
              }
          Severity: Major
          Found in cmd/kubevpn/cmds/quit.go - About 35 mins to fix

            Method ConnectOptions.LeaveProxyResources has 5 return statements (exceeds 4 allowed).
            Open

            func (c *ConnectOptions) LeaveProxyResources(ctx context.Context) (err error) {
                if c == nil || c.clientset == nil {
                    return
                }
            
            
            Severity: Major
            Found in pkg/handler/reset.go - About 35 mins to fix

              Method CloneOptions.setEnv has 5 return statements (exceeds 4 allowed).
              Open

              func (d *CloneOptions) setEnv(u *unstructured.Unstructured) error {
                  temp, path, err := util.GetPodTemplateSpecPath(u)
                  if err != nil {
                      return err
                  }
              Severity: Major
              Found in pkg/handler/clone.go - About 35 mins to fix

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

                func NeedsUpgrade(ctx context.Context, client *http.Client, version string) (url string, latestVersion string, upgrade bool, err error) {
                    latestVersion, url, err = util.GetManifest(client, runtime.GOOS, runtime.GOARCH)
                    if err != nil {
                        v := "https://github.com/kubenetworks/kubevpn/raw/master/plugins/stable.txt"
                        var stream []byte
                Severity: Major
                Found in pkg/upgrade/upgrade.go - About 35 mins to fix

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

                  func GetNsForListPodAndSvc(ctx context.Context, clientset *kubernetes.Clientset, nsList []string) (podNs string, svcNs string, err error) {
                      for _, ns := range nsList {
                          log.Debugf("List namepsace %s pods", ns)
                          _, err = clientset.CoreV1().Pods(ns).List(ctx, metav1.ListOptions{Limit: 1})
                          if apierrors.IsForbidden(err) {
                  Severity: Major
                  Found in pkg/util/route.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 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 runLogsWaitRunning has 5 return statements (exceeds 4 allowed).
                        Open

                        func runLogsWaitRunning(ctx context.Context, dockerCli command.Cli, id string) error {
                            c, err := dockerCli.Client().ContainerInspect(ctx, id)
                            if err != nil {
                                return err
                            }
                        Severity: Major
                        Found in pkg/dev/docker_utils.go - About 35 mins to fix

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

                          func NewOnAddresses(dialer httpstream.Dialer, addresses []string, ports []string, stopChan <-chan struct{}, readyChan chan struct{}, out, errOut io.Writer) (*PortForwarder, error) {
                              if len(addresses) == 0 {
                                  return nil, errors.New("you must specify at least 1 address")
                              }
                              parsedAddresses, err := parseAddresses(addresses)
                          Severity: Major
                          Found in pkg/util/portforward.go - About 35 mins to fix

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

                            func cmdConfigAdd(f cmdutil.Factory) *cobra.Command {
                                var sshConf = &pkgssh.SshConfig{}
                                cmd := &cobra.Command{
                                    Use:   "add",
                                    Short: i18n.T("Proxy kubeconfig"),
                            Severity: Major
                            Found in cmd/kubevpn/cmds/config.go - About 35 mins to fix

                              Method ConnectOptions.PreCheckResource has 5 return statements (exceeds 4 allowed).
                              Open

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

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

                                func parsePorts(ports []string) ([]ForwardedPort, error) {
                                    var forwards []ForwardedPort
                                    for _, portString := range ports {
                                        parts := strings.Split(portString, ":")
                                        var localString, remoteString string
                                Severity: Major
                                Found in pkg/util/portforward.go - About 35 mins to fix

                                  Method ConnectOptions.getCIDR has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func (c *ConnectOptions) getCIDR(ctx context.Context, m *dhcp.Manager) (err error) {
                                      defer func() {
                                          if err == nil {
                                              u, err2 := url.Parse(c.config.Host)
                                              if err2 != nil {
                                  Severity: Major
                                  Found in pkg/handler/connect.go - About 35 mins to fix

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

                                    func removeInboundContainer(factory util.Factory, namespace, workloads string) error {
                                        object, err := util2.GetUnstructuredObject(factory, namespace, workloads)
                                        if err != nil {
                                            return err
                                        }
                                    Severity: Major
                                    Found in pkg/inject/proxy.go - About 35 mins to fix

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

                                      func CmdReset(f cmdutil.Factory) *cobra.Command {
                                          var sshConf = &pkgssh.SshConfig{}
                                          cmd := &cobra.Command{
                                              Use:   "reset",
                                              Short: "Reset all resource create by kubevpn in k8s cluster",
                                      Severity: Major
                                      Found in cmd/kubevpn/cmds/reset.go - About 35 mins to fix

                                        Function genProxyMsg has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                                        Open

                                        func genProxyMsg(w *tabwriter.Writer, list []*rpc.Status) {
                                            var needsPrint bool
                                            for _, status := range list {
                                                if len(status.ProxyList) != 0 {
                                                    needsPrint = true
                                        Severity: Minor
                                        Found in cmd/kubevpn/cmds/status.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

                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language