kubenetworks/kubevpn

View on GitHub

Showing 333 of 526 total issues

Method SvrOption.Start has 67 lines of code (exceeds 50 allowed). Consider refactoring.
Open

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

    Function createTun has 67 lines of code (exceeds 50 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_windows.go - About 1 hr to fix

      Function gen has 67 lines of code (exceeds 50 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 1 hr to fix

        Method ConnectOptions.DoConnect has 66 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (c *ConnectOptions) DoConnect(ctx context.Context, isLite bool) (err error) {
            c.ctx, c.cancel = context.WithCancel(ctx)
        
            log.Info("Starting connect")
            m := dhcp.NewDHCPManager(c.clientset.CoreV1().ConfigMaps(c.Namespace), c.Namespace)
        Severity: Minor
        Found in pkg/handler/connect.go - About 1 hr to fix

          Function CmdAlias has 66 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func CmdAlias(f cmdutil.Factory) *cobra.Command {
              var localFile, remoteAddr string
              cmd := &cobra.Command{
                  Use:   "alias",
                  Short: i18n.T("Config file alias to execute command simply"),
          Severity: Minor
          Found in cmd/kubevpn/cmds/alias.go - About 1 hr to fix

            Method ConnectOptions.setupDNS has 66 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (c *ConnectOptions) setupDNS(ctx context.Context) error {
                const port = 53
                const portTCP = 10800
                pod, err := c.GetRunningPodList(ctx)
                if err != nil {
            Severity: Minor
            Found in pkg/handler/connect.go - About 1 hr to fix

              Method wsHandler.installKubevpnOnRemote has 66 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (w *wsHandler) installKubevpnOnRemote(ctx context.Context, sshClient *ssh.Client) (err error) {
                  defer func() {
                      if err == nil {
                          w.Log("Remote daemon server version: %s", startDaemonProcess(sshClient))
                      }
              Severity: Minor
              Found in pkg/daemon/handler/ssh.go - About 1 hr to fix

                Method Krb5InitiatorClient.InitSecContext has 66 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (k *Krb5InitiatorClient) InitSecContext(target string, token []byte, isGSSDelegCreds bool) ([]byte, bool, error) {
                    GSSAPIFlags := []int{
                        ContextFlagREADY,
                        gssapi.ContextFlagInteg,
                        gssapi.ContextFlagMutual,
                Severity: Minor
                Found in pkg/ssh/gssapi.go - About 1 hr to fix

                  Function CmdGet has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func CmdGet(f cmdutil.Factory) *cobra.Command {
                      var printFlags = cmdget.NewGetPrintFlags()
                      cmd := &cobra.Command{
                          Use:    "get",
                          Hidden: true,
                  Severity: Minor
                  Found in cmd/kubevpn/cmds/get.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 createContainer has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func createContainer(ctx context.Context, dockerCli command.Cli, runConfig *RunConfig) (string, error) {
                      config := runConfig.config
                      hostConfig := runConfig.hostConfig
                      networkingConfig := runConfig.networkingConfig
                      var (
                  Severity: Minor
                  Found in pkg/dev/docker_utils.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 createOutboundPod has 17 return statements (exceeds 4 allowed).
                  Open

                  func createOutboundPod(ctx context.Context, factory cmdutil.Factory, clientset *kubernetes.Clientset, namespace string) (err error) {
                      innerIpv4CIDR := net.IPNet{IP: config.RouterIP, Mask: config.CIDR.Mask}
                      innerIpv6CIDR := net.IPNet{IP: config.RouterIP6, Mask: config.CIDR6.Mask}
                  
                      service, err := clientset.CoreV1().Services(namespace).Get(ctx, config.ConfigMapPodTrafficManager, metav1.GetOptions{})
                  Severity: Major
                  Found in pkg/handler/remote.go - About 1 hr to fix

                    Function runContainer has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func runContainer(ctx context.Context, dockerCli command.Cli, runConfig *RunConfig) error {
                        config := runConfig.config
                        stdout, stderr := dockerCli.Out(), dockerCli.Err()
                        apiClient := dockerCli.Client()
                    
                    
                    Severity: Minor
                    Found in pkg/dev/docker_utils.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 CloneOptions.DoClone has 17 return statements (exceeds 4 allowed).
                    Open

                    func (d *CloneOptions) DoClone(ctx context.Context, kubeconfigJsonBytes []byte) error {
                        var args []string
                        if len(d.Headers) != 0 {
                            args = append(args, "--headers", labels.Set(d.Headers).String())
                        }
                    Severity: Major
                    Found in pkg/handler/clone.go - About 1 hr to fix

                      Method CopyOptions.untarAll has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (o *CopyOptions) untarAll(prefix string, dest localPath, reader io.Reader) error {
                          // TODO: use compression here?
                          tarReader := tar.NewReader(reader)
                          var linkList []tar.Header
                          var genDstFilename = func(headerName string) localPath {
                      Severity: Minor
                      Found in pkg/cp/cp.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 ConnectOptions.upgradeDeploy has 64 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (c *ConnectOptions) upgradeDeploy(ctx context.Context) error {
                          deploy, err := c.clientset.AppsV1().Deployments(c.Namespace).Get(ctx, config.ConfigMapPodTrafficManager, metav1.GetOptions{})
                          if err != nil {
                              return err
                          }
                      Severity: Minor
                      Found in pkg/handler/connect.go - About 1 hr to fix

                        Function CmdStatus has 64 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func CmdStatus(f cmdutil.Factory) *cobra.Command {
                            var aliasName string
                            var localFile string
                            var remoteAddr string
                            var format string
                        Severity: Minor
                        Found in cmd/kubevpn/cmds/status.go - About 1 hr to fix

                          Function legacyWaitExitOrRemoved has 64 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func legacyWaitExitOrRemoved(ctx context.Context, apiClient client.APIClient, containerID string, waitRemove bool) <-chan int {
                              var removeErr error
                              statusChan := make(chan int)
                              exitCode := 125
                          
                          
                          Severity: Minor
                          Found in pkg/dev/docker_utils.go - About 1 hr to fix

                            Method Server.SshStart has 64 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (svr *Server) SshStart(ctx context.Context, req *rpc.SshStartRequest) (resp *rpc.SshStartResponse, err error) {
                                mux.Lock()
                                defer mux.Unlock()
                            
                                var clientIP net.IP
                            Severity: Minor
                            Found in pkg/daemon/action/sshdaemon.go - About 1 hr to fix

                              Function TransferImage has 16 return statements (exceeds 4 allowed).
                              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: Major
                              Found in pkg/ssh/image.go - About 1 hr to fix

                                Function CmdReset has 62 lines of code (exceeds 50 allowed). Consider refactoring.
                                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: Minor
                                Found in cmd/kubevpn/cmds/reset.go - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language