kubenetworks/kubevpn

View on GitHub
pkg/daemon/handler/ssh.go

Summary

Maintainability
C
1 day
Test Coverage

Method wsHandler.handle has 88 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (w *wsHandler) handle(c context.Context) {
    ctx, f := context.WithCancel(c)
    defer f()

    cli, err := pkgssh.DialSshRemote(ctx, w.sshConfig, ctx.Done())
Severity: Major
Found in pkg/daemon/handler/ssh.go - About 2 hrs to fix

    Function init has 69 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func init() {
        http.Handle("/ws", websocket.Handler(func(conn *websocket.Conn) {
            var sshConfig pkgssh.SshConfig
            b := conn.Request().Header.Get("ssh")
            if err := json.Unmarshal([]byte(b), &sshConfig); err != nil {
    Severity: Minor
    Found in pkg/daemon/handler/ssh.go - About 1 hr to fix

      Method wsHandler.installKubevpnOnRemote has 66 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (w *wsHandler) installKubevpnOnRemote(ctx context.Context, sshClient *ssh.Client) (err error) {
          defer func() {
              if err == nil {
                  w.Log("Remote daemon server version: %s", startDaemonProcess(sshClient))
              }
      Severity: Minor
      Found in pkg/daemon/handler/ssh.go - About 1 hr to fix

        Method wsHandler.handle has 11 return statements (exceeds 4 allowed).
        Open

        func (w *wsHandler) handle(c context.Context) {
            ctx, f := context.WithCancel(c)
            defer f()
        
            cli, err := pkgssh.DialSshRemote(ctx, w.sshConfig, ctx.Done())
        Severity: Major
        Found in pkg/daemon/handler/ssh.go - About 1 hr to fix

          Method wsHandler.installKubevpnOnRemote has 11 return statements (exceeds 4 allowed).
          Open

          func (w *wsHandler) installKubevpnOnRemote(ctx context.Context, sshClient *ssh.Client) (err error) {
              defer func() {
                  if err == nil {
                      w.Log("Remote daemon server version: %s", startDaemonProcess(sshClient))
                  }
          Severity: Major
          Found in pkg/daemon/handler/ssh.go - About 1 hr to fix

            Function init has 6 return statements (exceeds 4 allowed).
            Open

            func init() {
                http.Handle("/ws", websocket.Handler(func(conn *websocket.Conn) {
                    var sshConfig pkgssh.SshConfig
                    b := conn.Request().Header.Get("ssh")
                    if err := json.Unmarshal([]byte(b), &sshConfig); err != nil {
            Severity: Major
            Found in pkg/daemon/handler/ssh.go - About 40 mins to fix

              Function init has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
              Open

              func init() {
                  http.Handle("/ws", websocket.Handler(func(conn *websocket.Conn) {
                      var sshConfig pkgssh.SshConfig
                      b := conn.Request().Header.Get("ssh")
                      if err := json.Unmarshal([]byte(b), &sshConfig); err != nil {
              Severity: Minor
              Found in pkg/daemon/handler/ssh.go - About 25 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

              There are no issues that match your filters.

              Category
              Status