kubenetworks/kubevpn

View on GitHub

Showing 526 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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      case v1beta1.SchemeGroupVersion.WithKind("AdmissionReview"):
                          requestedAdmissionReview, ok := obj.(*v1beta1.AdmissionReview)
                          if !ok {
                              log.Errorf("Expected v1beta1.AdmissionReview but got: %T", obj)
                              return
                  Severity: Major
                  Found in pkg/webhook/mutateadmissionwebhook.go and 1 other location - About 2 hrs to fix
                  pkg/webhook/mutateadmissionwebhook.go on lines 109..133

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 245.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      case v1.SchemeGroupVersion.WithKind("AdmissionReview"):
                          requestedAdmissionReview, ok := obj.(*v1.AdmissionReview)
                          if !ok {
                              log.Errorf("Expected v1.AdmissionReview but got: %T", obj)
                              return
                  Severity: Major
                  Found in pkg/webhook/mutateadmissionwebhook.go and 1 other location - About 2 hrs to fix
                  pkg/webhook/mutateadmissionwebhook.go on lines 84..108

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 245.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  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

                          Severity
                          Category
                          Status
                          Source
                          Language