kubenetworks/kubevpn

View on GitHub

Showing 333 of 526 total issues

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

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

        func (d *CloneOptions) Cleanup(workloads ...string) error {
            if len(workloads) == 0 {
                workloads = d.Workloads
            }
            for _, workload := range workloads {
        Severity: Major
        Found in pkg/handler/clone.go - About 35 mins to fix

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

            Method SshConfig.GetAuth has 5 return statements (exceeds 4 allowed).
            Open

            func (config SshConfig) GetAuth() ([]ssh.AuthMethod, error) {
                host, _, _ := net.SplitHostPort(config.Addr)
                var auth []ssh.AuthMethod
                var c Krb5InitiatorClient
                var err error
            Severity: Major
            Found in pkg/ssh/ssh.go - About 35 mins to fix

              Method CCache.Unmarshal has 5 return statements (exceeds 4 allowed).
              Open

              func (c *CCache) Unmarshal(b []byte) error {
                  p := 0
                  //The first byte of the file always has the value 5
                  if int8(b[p]) != 5 {
                      return errors.New("Invalid credential cache data. First byte does not equal 5")
              Severity: Major
              Found in pkg/ssh/gssapi_ccache.go - About 35 mins to fix

                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

                  Method CCache.writeV4Header has 5 return statements (exceeds 4 allowed).
                  Open

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

                    Method Client.Call has 5 return statements (exceeds 4 allowed).
                    Open

                    func (c *Client) Call(ctx context.Context, uri, method string, body []byte) ([]byte, error) {
                        var url = path.Join(c.GUIAddress, uri)
                        req, err := http.NewRequest(method, fmt.Sprintf("http://%s", url), bytes.NewBuffer(body))
                        if err != nil {
                            return nil, fmt.Errorf("failed to initialize syncthing API request: %w", err)
                    Severity: Major
                    Found in pkg/syncthing/api.go - About 35 mins to fix

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

                      func Main(ctx context.Context, filename string, port uint, logger *log.Logger) error {
                          snapshotCache := cache.NewSnapshotCache(false, cache.IDHash{}, logger)
                          proc := NewProcessor(snapshotCache, logger)
                      
                          errChan := make(chan error, 2)
                      Severity: Major
                      Found in pkg/controlplane/main.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() {
                                util.InitLoggerForServer(true)
                                log.SetOutput(svr.LogFile)
                                config.Debug = false
                        Severity: Major
                        Found in pkg/daemon/action/reset.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 := config.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

                            Function createTun has a Cognitive Complexity of 22 (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_bsd.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 Options.CreateConnectContainer has 5 return statements (exceeds 4 allowed).
                            Open

                            func (option *Options) CreateConnectContainer(portBindings nat.PortMap) (*RunConfig, error) {
                                portMap, portSet, err := option.GetExposePort(portBindings)
                                if err != nil {
                                    return nil, err
                                }
                            Severity: Major
                            Found in pkg/dev/options.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 Main has 5 return statements (exceeds 4 allowed).
                                Open

                                func Main(f util.Factory) error {
                                    clientset, err := f.KubernetesClientSet()
                                    if err != nil {
                                        return err
                                    }
                                Severity: Major
                                Found in pkg/webhook/main.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(config.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 Processor.ProcessFile has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func (p *Processor) ProcessFile(file NotifyMessage) error {
                                      configList, err := ParseYaml(file.FilePath)
                                      if err != nil {
                                          p.logger.Errorf("error parsing yaml file: %+v", err)
                                          return err
                                  Severity: Major
                                  Found in pkg/controlplane/processor.go - About 35 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language