kubenetworks/kubevpn

View on GitHub

Showing 333 of 526 total issues

Method CCache.writeCredential has 109 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (c *CCache) writeCredential(cred *Credential, endian *binary.ByteOrder) ([]byte, error) {
    var byteString bytes.Buffer
    var err error

    b := &byteString
Severity: Major
Found in pkg/ssh/gssapi_ccache.go - About 3 hrs to fix

    Method Server.Get has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
    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: Minor
    Found in pkg/daemon/action/get.go - About 3 hrs 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 104 lines of code (exceeds 50 allowed). Consider refactoring.
    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 3 hrs to fix

      Method ConnectOptions.PreCheckResource has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
      Open

      func (c *ConnectOptions) PreCheckResource() error {
          if len(c.Workloads) == 0 {
              return nil
          }
      
      
      Severity: Minor
      Found in pkg/handler/connect.go - About 3 hrs 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 a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
      Open

      func (option *Options) Dev(ctx context.Context, cConfig *Config, hostConfig *HostConfig) error {
          templateSpec, err := option.GetPodTemplateSpec()
          if err != nil {
              return err
          }
      Severity: Minor
      Found in pkg/dev/options.go - About 3 hrs 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 102 lines of code (exceeds 50 allowed). Consider refactoring.
      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 3 hrs to fix

        Method CloneOptions.setEnv has 102 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (d *CloneOptions) setEnv(u *unstructured.Unstructured) error {
            temp, path, err := util.GetPodTemplateSpecPath(u)
            if err != nil {
                return err
            }
        Severity: Major
        Found in pkg/handler/clone.go - About 3 hrs to fix

          Method Server.Clone has 101 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (svr *Server) Clone(req *rpc.CloneRequest, resp rpc.Daemon_CloneServer) (err error) {
              defer func() {
                  util.InitLoggerForServer(true)
                  log.SetOutput(svr.LogFile)
                  config.Debug = false
          Severity: Major
          Found in pkg/daemon/action/clone.go - About 3 hrs to fix

            Function AddContainer has 100 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func AddContainer(spec *corev1.PodSpec, c util.PodRouteConfig) {
                // remove vpn container if already exist
                RemoveContainer(spec)
                spec.Containers = append(spec.Containers, corev1.Container{
                    Name:  config.ContainerSidecarVPN,
            Severity: Major
            Found in pkg/inject/exchange.go - About 3 hrs to fix

              ConnectOptions has 26 methods (exceeds 20 allowed). Consider refactoring.
              Open

              type ConnectOptions struct {
                  Namespace            string
                  Headers              map[string]string
                  PortMap              []string
                  Workloads            []string
              Severity: Minor
              Found in pkg/handler/connect.go - About 3 hrs to fix

                Function NewTunEndpoint has 99 lines of code (exceeds 50 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 {
                    addr, _ := tcpip.ParseMACAddress("02:03:03:04:05:06")
                    endpoint := channel.New(tcp.DefaultReceiveBufferSize, mtu, addr)
                
                    go func() {
                Severity: Major
                Found in pkg/core/gvisortunendpoint.go - About 2 hrs to fix

                  Method ConnectOptions.portForward has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (c *ConnectOptions) portForward(ctx context.Context, portPair []string) error {
                      firstCtx, firstCancelFunc := context.WithCancel(ctx)
                      defer firstCancelFunc()
                      var errChan = make(chan error, 1)
                      go func() {
                  Severity: Minor
                  Found in pkg/handler/connect.go - About 2 hrs 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 CCache.writeCredential has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (c *CCache) writeCredential(cred *Credential, endian *binary.ByteOrder) ([]byte, error) {
                      var byteString bytes.Buffer
                      var err error
                  
                      b := &byteString
                  Severity: Minor
                  Found in pkg/ssh/gssapi_ccache.go - About 2 hrs 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 TransferImage has 96 lines of code (exceeds 50 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: Major
                  Found in pkg/ssh/image.go - About 2 hrs to fix

                    File docker_utils.go has 533 lines of code (exceeds 500 allowed). Consider refactoring.
                    Open

                    package dev
                    
                    import (
                        "bytes"
                        "context"
                    Severity: Minor
                    Found in pkg/dev/docker_utils.go - About 2 hrs to fix

                      Function PortMapUntil has 94 lines of code (exceeds 50 allowed). Consider refactoring.
                      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 2 hrs to fix

                        Function StartServer has 94 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func StartServer(ctx context.Context, detach bool, remoteDir string) error {
                            if err := MakeSureGui(); err != nil {
                                return err
                            }
                        
                        
                        Severity: Major
                        Found in pkg/syncthing/syncthing.go - About 2 hrs to fix

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

                          func (c *ConnectOptions) Cleanup() {
                              if c == nil {
                                  return
                              }
                          
                          
                          Severity: Minor
                          Found in pkg/handler/cleaner.go - About 2 hrs 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 Server.Connect has 93 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (svr *Server) Connect(req *rpc.ConnectRequest, resp rpc.Daemon_ConnectServer) (e error) {
                              defer func() {
                                  util.InitLoggerForServer(true)
                                  log.SetOutput(svr.LogFile)
                                  config.Debug = false
                          Severity: Major
                          Found in pkg/daemon/action/connect.go - About 2 hrs to fix

                            CloneRequest has 24 methods (exceeds 20 allowed). Consider refactoring.
                            Open

                            type CloneRequest struct {
                                state         protoimpl.MessageState
                                sizeCache     protoimpl.SizeCache
                                unknownFields protoimpl.UnknownFields
                            
                            
                            Severity: Minor
                            Found in pkg/daemon/rpc/daemon.pb.go - About 2 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language