kubenetworks/kubevpn

View on GitHub

Showing 333 of 526 total issues

Method CCache.Marshal has 8 return statements (exceeds 4 allowed).
Open

func (c *CCache) Marshal() ([]byte, error) {
    var b bytes.Buffer
    var err error
    endian := c.getEndian()

Severity: Major
Found in pkg/ssh/gssapi_ccache.go - About 50 mins to fix

    Method Route.GenerateServers has 8 return statements (exceeds 4 allowed).
    Open

    func (r *Route) GenerateServers() ([]Server, error) {
        chain, err := r.parseChain()
        if err != nil && !errors.Is(err, ErrorInvalidNode) {
            log.Errorf("Failed to parse chain: %v", err)
            return nil, err
    Severity: Major
    Found in pkg/core/route.go - About 50 mins to fix

      Method CloneOptions.Cleanup has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
      Open

      func (d *CloneOptions) Cleanup(workloads ...string) error {
          if len(workloads) == 0 {
              workloads = d.Workloads
          }
          for _, workload := range workloads {
      Severity: Minor
      Found in pkg/handler/clone.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

      Method Connects.Less has 7 return statements (exceeds 4 allowed).
      Open

      func (s Connects) Less(i, j int) bool {
          a := s[i]
          b := s[j]
      
          if a == nil {
      Severity: Major
      Found in pkg/handler/sort.go - About 45 mins to fix

        Function GetVolume has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
        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: Minor
        Found in pkg/util/volume.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

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

        func attachContainer(ctx context.Context, dockerCli command.Cli, containerID string, errCh *chan error, config *container.Config, options container.AttachOptions) (func(), error) {
        Severity: Minor
        Found in pkg/dev/docker_utils.go - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

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

            Function genOutput has 7 return statements (exceeds 4 allowed).
            Open

            func genOutput(status *rpc.StatusResponse, format string) (string, error) {
                switch format {
                case FormatJson:
                    if len(status.List) == 0 {
                        return "", nil
            Severity: Major
            Found in cmd/kubevpn/cmds/status.go - About 45 mins to fix

              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

                Function GetClusterIDByConfig has 7 return statements (exceeds 4 allowed).
                Open

                func GetClusterIDByConfig(cmd *cobra.Command, config Config) (string, error) {
                    flags := flag.NewFlagSet("", flag.ContinueOnError)
                    var sshConf = &pkgssh.SshConfig{}
                    pkgssh.AddSshFlags(flags, sshConf)
                    handler.AddExtraRoute(flags, &handler.ExtraRouteInfo{})
                Severity: Major
                Found in cmd/kubevpn/cmds/status.go - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if len(comps) > 0 && len(toComplete) > 0 {
                                          if files, err := os.ReadDir("."); err == nil {
                                              for _, file := range files {
                                                  filename := file.Name()
                                                  if strings.HasPrefix(filename, toComplete) {
                  Severity: Major
                  Found in cmd/kubevpn/cmds/cp.go - About 45 mins to fix

                    Function InjectVPNSidecar has 7 return statements (exceeds 4 allowed).
                    Open

                    func InjectVPNSidecar(ctx1 context.Context, factory util.Factory, namespace, workload string, c util2.PodRouteConfig) error {
                        object, err := util2.GetUnstructuredObject(factory, namespace, workload)
                        if err != nil {
                            return err
                        }
                    Severity: Major
                    Found in pkg/inject/proxy.go - About 45 mins to fix

                      Function ConvertToKubeConfigBytes has 7 return statements (exceeds 4 allowed).
                      Open

                      func ConvertToKubeConfigBytes(factory cmdutil.Factory) ([]byte, string, error) {
                          loader := factory.ToRawKubeConfigLoader()
                          namespace, _, err := loader.Namespace()
                          if err != nil {
                              return nil, "", err
                      Severity: Major
                      Found in pkg/util/ns.go - About 45 mins to fix

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

                        func run(ctx context.Context, cli *client.Client, dockerCli *command.DockerCli, runConfig *RunConfig) (id string, err error) {
                            rand.New(rand.NewSource(time.Now().UnixNano()))
                        
                            var config = runConfig.config
                            var hostConfig = runConfig.hostConfig
                        Severity: Minor
                        Found in pkg/dev/docker_utils.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

                        Function CmdStatus has 7 return statements (exceeds 4 allowed).
                        Open

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

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

                          func CmdDisconnect(f cmdutil.Factory) *cobra.Command {
                              var all = false
                              var clusterIDs []string
                              cmd := &cobra.Command{
                                  Use:   "disconnect",
                          Severity: Minor
                          Found in cmd/kubevpn/cmds/disconnect.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

                          Function Parse has 7 return statements (exceeds 4 allowed).
                          Open

                          func Parse(flags *pflag.FlagSet, copts *ContainerOptions) (*Config, *HostConfig, error) {
                              var (
                                  attachStdin  = copts.attach.Get("stdin")
                                  attachStdout = copts.attach.Get("stdout")
                                  attachStderr = copts.attach.Get("stderr")
                          Severity: Major
                          Found in pkg/dev/docker_opts.go - About 45 mins to fix

                            Method ConnectOptions.setupDNS has 7 return statements (exceeds 4 allowed).
                            Open

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

                              Avoid deeply nested control flow statements.
                              Open

                                                      if absHostPart, err := filepath.Abs(hostPart); err == nil {
                                                          hostPart = absHostPart
                                                      }
                              Severity: Major
                              Found in pkg/dev/docker_opts.go - About 45 mins to fix

                                Function monitorSize has 7 return statements (exceeds 4 allowed).
                                Open

                                func monitorSize(ctx context.Context, sessionID string) error {
                                    conn := daemon.GetTCPClient(true)
                                    if conn == nil {
                                        return fmt.Errorf("conn is nil")
                                    }
                                Severity: Major
                                Found in cmd/kubevpn/cmds/ssh.go - About 45 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language