kubenetworks/kubevpn

View on GitHub

Showing 333 of 526 total issues

Avoid deeply nested control flow statements.
Open

                    } else if err != nil {
                        return err
                    }
Severity: Major
Found in cmd/kubevpn/cmds/connect.go - About 45 mins to fix

    Method CloneOptions.SyncDir has 7 return statements (exceeds 4 allowed).
    Open

    func (d *CloneOptions) SyncDir(ctx context.Context, labels string) error {
        list, err := util.GetRunningPodList(ctx, d.targetClientset, d.TargetNamespace, labels)
        if err != nil {
            return err
        }
    Severity: Major
    Found in pkg/handler/clone.go - About 45 mins to fix

      Function NewOnAddresses has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func NewOnAddresses(dialer httpstream.Dialer, addresses []string, ports []string, stopChan <-chan struct{}, readyChan chan struct{}, out, errOut io.Writer) (*PortForwarder, error) {
      Severity: Minor
      Found in pkg/util/portforward.go - About 45 mins to fix

        Method SvrOption.Start has 7 return statements (exceeds 4 allowed).
        Open

        func (o *SvrOption) Start(ctx context.Context) error {
            l := &lumberjack.Logger{
                Filename:   action.GetDaemonLogPath(),
                MaxSize:    100,
                MaxAge:     3,
        Severity: Major
        Found in pkg/daemon/daemon.go - About 45 mins to fix

          Function TransferImage has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
          Open

          func TransferImage(ctx context.Context, conf *SshConfig, imageSource, imageTarget string, out io.Writer) error {
              client, cli, err := GetClient()
              if err != nil {
                  log.Errorf("Failed to get docker client: %v", err)
                  return err
          Severity: Minor
          Found in pkg/ssh/image.go - About 45 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

          Avoid deeply nested control flow statements.
          Open

                  if config.Keyfile == "" {
                      config.Keyfile = filepath.Join(homedir.HomeDir(), ".ssh", "id_rsa")
                  }
          Severity: Major
          Found in pkg/ssh/ssh.go - About 45 mins to fix

            Method CopyOptions.Run has 7 return statements (exceeds 4 allowed).
            Open

            func (o *CopyOptions) Run() error {
                srcSpec, err := extractFileSpec(o.args[0])
                if err != nil {
                    return err
                }
            Severity: Major
            Found in pkg/cp/cp.go - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                      if err != nil {
                          return nil, err
                      }
              Severity: Major
              Found in pkg/ssh/ssh.go - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                } else if lookup.DefValue != "" {
                                    configFlags.KubeConfig = pointer.String(lookup.DefValue)
                                }
                Severity: Major
                Found in pkg/ssh/ssh.go - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                          } else if code := status.Code(err); code == codes.AlreadyExists {
                              return fmt.Errorf("connect with cluster already established, disconnect required before proceeding")
                          } else {
                              return err
                          }
                  Severity: Major
                  Found in pkg/daemon/action/clone.go - About 45 mins to fix

                    Method Manager.RentIP has 7 return statements (exceeds 4 allowed).
                    Open

                    func (m *Manager) RentIP(ctx context.Context) (*net.IPNet, *net.IPNet, error) {
                        addrs, _ := net.InterfaceAddrs()
                        var isAlreadyExistedFunc = func(ip net.IP) bool {
                            for _, addr := range addrs {
                                if addr == nil {
                    Severity: Major
                    Found in pkg/dhcp/dhcp.go - About 45 mins to fix

                      Function PullImage has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      func PullImage(ctx context.Context, platform *v1.Platform, cli *client.Client, dockerCli *command.DockerCli, img string, out io.Writer) error {
                      Severity: Minor
                      Found in pkg/ssh/image.go - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                        } else if err != nil {
                                            log.Errorf("Receive from disconnect failed: %v", err)
                                            return err
                                        }
                        Severity: Major
                        Found in pkg/daemon/action/proxy.go - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                  if err != nil {
                                      return nil, err
                                  }
                          Severity: Major
                          Found in pkg/ssh/ssh.go - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                            } else if lookup.DefValue != "" {
                                                path = lookup.DefValue
                                            } else {
                                                path = lookup.NoOptDefVal
                                            }
                            Severity: Major
                            Found in pkg/ssh/ssh.go - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                          } else if event.Op&fsnotify.Remove == fsnotify.Remove {
                                              notifyCh <- NotifyMessage{
                                                  Operation: Remove,
                                                  FilePath:  event.Name,
                                              }
                              Severity: Major
                              Found in pkg/controlplane/watcher.go - About 45 mins to fix

                                Method CCache.writePrincipal has 7 return statements (exceeds 4 allowed).
                                Open

                                func (c *CCache) writePrincipal(p principal, endian *binary.ByteOrder) ([]byte, error) {
                                    var byteString bytes.Buffer
                                    var err error
                                
                                    b := &byteString
                                Severity: Major
                                Found in pkg/ssh/gssapi_ccache.go - About 45 mins to fix

                                  Function NewTunEndpoint has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                  func NewTunEndpoint(ctx context.Context, tun net.Conn, mtu uint32, engine config.Engine, in chan<- *DataElem, out chan *DataElem) stack.LinkEndpoint {
                                  Severity: Minor
                                  Found in pkg/core/gvisortunendpoint.go - About 45 mins to fix

                                    Method hijackedIOStreamer.stream has 7 return statements (exceeds 4 allowed).
                                    Open

                                    func (h *hijackedIOStreamer) stream(ctx context.Context) error {
                                        restoreInput, err := h.setupInput()
                                        if err != nil {
                                            return fmt.Errorf("unable to setup input stream: %s", err)
                                        }
                                    Severity: Major
                                    Found in pkg/dev/docker_hijack.go - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                              if net.ParseIP(svc.Spec.ClusterIP) == nil {
                                                                  continue
                                                              }
                                      Severity: Major
                                      Found in pkg/dns/dns.go - About 45 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language