kubenetworks/kubevpn

View on GitHub

Showing 333 of 526 total issues

Function GetClient has 9 return statements (exceeds 4 allowed).
Open

func GetClient(isSudo bool) (cli rpc.DaemonClient) {
    sockPath := config.GetSockPath(isSudo)
    if _, err := os.Stat(sockPath); errors.Is(err, os.ErrNotExist) {
        return nil
    }
Severity: Major
Found in pkg/daemon/client.go - About 55 mins to fix

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

      Method admissionReviewHandler.handleCreate has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
      Open

      func (h *admissionReviewHandler) handleCreate(ar v1.AdmissionReview) *v1.AdmissionResponse {
          raw := ar.Request.Object.Raw
          pod := corev1.Pod{}
          deserializer := codecs.UniversalDeserializer()
          if _, _, err := deserializer.Decode(raw, nil, &pod); err != nil {
      Severity: Minor
      Found in pkg/webhook/pods.go - About 55 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 createTun has a Cognitive Complexity of 24 (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_windows.go - About 55 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.Dev has 9 return statements (exceeds 4 allowed).
      Open

      func (option *Options) Dev(ctx context.Context, cConfig *Config, hostConfig *HostConfig) error {
          templateSpec, err := option.GetPodTemplateSpec()
          if err != nil {
              return err
          }
      Severity: Major
      Found in pkg/dev/options.go - About 55 mins to fix

        Method Server.Get has 9 return statements (exceeds 4 allowed).
        Open

        func (svr *Server) Get(ctx context.Context, req *rpc.GetRequest) (*rpc.GetResponse, error) {
            if svr.connect == nil || svr.connect.Context() == nil {
                return nil, errors.New("not connected")
            }
            if svr.resourceLists == nil {
        Severity: Major
        Found in pkg/daemon/action/get.go - About 55 mins to fix

          Method Krb5InitiatorClient.InitSecContext has 9 return statements (exceeds 4 allowed).
          Open

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

            Function PortMapUntil has 9 return statements (exceeds 4 allowed).
            Open

            func PortMapUntil(ctx context.Context, conf *SshConfig, remote, local netip.AddrPort) error {
                // Listen on remote server port
                var lc net.ListenConfig
                localListen, e := lc.Listen(ctx, "tcp", local.String())
                if e != nil {
            Severity: Major
            Found in pkg/ssh/ssh.go - About 55 mins to fix

              Method SvrOption.detectUnixSocksFile has 9 return statements (exceeds 4 allowed).
              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: Major
              Found in pkg/daemon/daemon.go - About 55 mins to fix

                Method server.ServeDNS has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                Open

                func (s *server) ServeDNS(w miekgdns.ResponseWriter, m *miekgdns.Msg) {
                    defer w.Close()
                    if len(m.Question) == 0 {
                        m.Response = true
                        _ = w.WriteMsg(m)
                Severity: Minor
                Found in pkg/dns/forwardserver.go - About 55 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.removeHosts has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                Open

                func (c *Config) removeHosts(hosts []Entry) error {
                    if len(hosts) == 0 {
                        return nil
                    }
                
                
                Severity: Minor
                Found in pkg/dns/dns.go - About 55 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 networkSetup has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                Open

                func networkSetup(ip string, namespace string) {
                    networkCancel()
                    b, err := exec.Command("networksetup", "-listallnetworkservices").Output()
                    if err != nil {
                        return
                Severity: Minor
                Found in pkg/dns/dns_unix.go - About 55 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 GetKubeconfigPath has 8 return statements (exceeds 4 allowed).
                Open

                func GetKubeconfigPath(factory cmdutil.Factory) (string, error) {
                    rawConfig, err := factory.ToRawKubeConfigLoader().RawConfig()
                    if err != nil {
                        return "", err
                    }
                Severity: Major
                Found in pkg/util/ns.go - About 50 mins to fix

                  Function CmdDisconnect has 8 return statements (exceeds 4 allowed).
                  Open

                  func CmdDisconnect(f cmdutil.Factory) *cobra.Command {
                      var all = false
                      var clusterIDs []string
                      cmd := &cobra.Command{
                          Use:   "disconnect",
                  Severity: Major
                  Found in cmd/kubevpn/cmds/disconnect.go - About 50 mins to fix

                    Function newer has 8 return statements (exceeds 4 allowed).
                    Open

                    func newer(clientImgStr, serverImgStr string) (bool, error) {
                        clientImg, err := reference.ParseNormalizedNamed(clientImgStr)
                        if err != nil {
                            return false, err
                        }
                    Severity: Major
                    Found in pkg/handler/connect.go - About 50 mins to fix

                      Function CreateAfterDeletePod has 8 return statements (exceeds 4 allowed).
                      Open

                      func CreateAfterDeletePod(factory util.Factory, p *v1.Pod, helper *resource.Helper) error {
                          _, err := helper.DeleteWithOptions(p.Namespace, p.Name, &v12.DeleteOptions{
                              GracePeriodSeconds: pointer.Int64(0),
                          })
                          if err != nil {
                      Severity: Major
                      Found in pkg/inject/proxy.go - About 50 mins to fix

                        Method CloneOptions.replaceRegistry has 8 return statements (exceeds 4 allowed).
                        Open

                        func (d *CloneOptions) replaceRegistry(u *unstructured.Unstructured) error {
                            // not pass this options, do nothing
                            if !d.IsChangeTargetRegistry {
                                return nil
                            }
                        Severity: Major
                        Found in pkg/handler/clone.go - About 50 mins to fix

                          Function Complete has 8 return statements (exceeds 4 allowed).
                          Open

                          func Complete(ctx context.Context, route *core.Route) error {
                              if v, ok := os.LookupEnv(config.EnvInboundPodTunIPv4); !ok || v != "" {
                                  return nil
                              }
                          
                          
                          Severity: Major
                          Found in pkg/handler/tools.go - About 50 mins to fix

                            Method Manager.ForEach has 8 return statements (exceeds 4 allowed).
                            Open

                            func (m *Manager) ForEach(ctx context.Context, fnv4 func(net.IP), fnv6 func(net.IP)) error {
                                cm, err := m.client.Get(ctx, config.ConfigMapPodTrafficManager, metav1.GetOptions{})
                                if err != nil {
                                    return fmt.Errorf("failed to get cm DHCP server, err: %v", err)
                                }
                            Severity: Major
                            Found in pkg/dhcp/dhcp.go - About 50 mins to fix

                              Method Options.Main has 8 return statements (exceeds 4 allowed).
                              Open

                              func (option *Options) Main(ctx context.Context, sshConfig *pkgssh.SshConfig, flags *pflag.FlagSet, transferImage bool) error {
                                  mode := typescontainer.NetworkMode(option.ContainerOptions.netMode.NetworkMode())
                                  if mode.IsContainer() {
                                      log.Infof("Network mode container is %s", mode.ConnectedContainer())
                                      inspect, err := option.cli.ContainerInspect(ctx, mode.ConnectedContainer())
                              Severity: Major
                              Found in pkg/dev/options.go - About 50 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language