Showing 333 of 526 total issues
Method Server.redirectConnectForkToSudoDaemon
has 13 return statements (exceeds 4 allowed). Open
Open
func (svr *Server) redirectConnectForkToSudoDaemon(req *rpc.ConnectRequest, resp rpc.Daemon_ConnectServer) (err error) {
cli := svr.GetClient(true)
if cli == nil {
return fmt.Errorf("sudo daemon not start")
}
Method Server.redirectToSudoDaemon
has 13 return statements (exceeds 4 allowed). Open
Open
func (svr *Server) redirectToSudoDaemon(req *rpc.ConnectRequest, resp rpc.Daemon_ConnectServer) (e error) {
cli := svr.GetClient(true)
if cli == nil {
return fmt.Errorf("sudo daemon not start")
}
Method Server.Proxy
has 13 return statements (exceeds 4 allowed). Open
Open
func (svr *Server) Proxy(req *rpc.ConnectRequest, resp rpc.Daemon_ProxyServer) (e error) {
defer func() {
util.InitLoggerForServer(true)
log.SetOutput(svr.LogFile)
config.Debug = false
Function handle
has 13 return statements (exceeds 4 allowed). Open
Open
func handle(ctx context.Context, tcpConn net.Conn, udpConn *net.UDPConn) {
defer udpConn.Close()
log.Debugf("[TUN-UDP] %s <-> %s", tcpConn.RemoteAddr(), udpConn.LocalAddr())
errChan := make(chan error, 2)
go func() {
Function networkCancel
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
Open
func networkCancel() {
b, err := exec.Command("networksetup", "-listallnetworkservices").CombinedOutput()
if err != nil {
return
}
- Read upRead up
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 downloadAndInstall
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func downloadAndInstall(client *http.Client, url string) error {
temp, err := os.CreateTemp("", "*.zip")
if err != nil {
return err
}
Method Manager.updateDHCPConfigMap
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (m *Manager) updateDHCPConfigMap(ctx context.Context, f func(ipv4 *ipallocator.Range, ipv6 *ipallocator.Range) error) error {
cm, err := m.client.Get(ctx, config.ConfigMapPodTrafficManager, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("failed to get configmap DHCP server, err: %v", err)
}
Function Complete
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func Complete(ctx context.Context, route *core.Route) error {
if v, ok := os.LookupEnv(config.EnvInboundPodTunIPv4); !ok || v != "" {
return nil
}
Function TCPForwarder
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TCPForwarder(s *stack.Stack) func(stack.TransportEndpointID, *stack.PacketBuffer) bool {
GvisorTCPForwardAddr := GvisorTCPForwardAddr
return tcp.NewForwarder(s, 0, 100000, func(request *tcp.ForwarderRequest) {
defer request.Complete(false)
id := request.ID()
Method ConnectOptions.addExtraRoute
has 12 return statements (exceeds 4 allowed). Open
Open
func (c *ConnectOptions) addExtraRoute(ctx context.Context, nameserver string) error {
if len(c.ExtraRouteInfo.ExtraDomain) == 0 {
return nil
}
Method Options.Connect
has 12 return statements (exceeds 4 allowed). Open
Open
func (option *Options) Connect(ctx context.Context, sshConfig *pkgssh.SshConfig, transferImage bool, portBindings nat.PortMap) error {
switch option.ConnectMode {
case ConnectModeHost:
daemonCli := daemon.GetClient(false)
if daemonCli == nil {
Method ConnectOptions.PreCheckResource
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *ConnectOptions) PreCheckResource() error {
if len(c.Workloads) == 0 {
return nil
}
Method SvrOption.detectUnixSocksFile
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
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()
Function CmdGet
has 11 return statements (exceeds 4 allowed). Open
Open
func CmdGet(f cmdutil.Factory) *cobra.Command {
var printFlags = cmdget.NewGetPrintFlags()
cmd := &cobra.Command{
Use: "get",
Hidden: true,
Function createTun
has 11 return statements (exceeds 4 allowed). Open
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
}
Method wsHandler.handle
has 11 return statements (exceeds 4 allowed). Open
Open
func (w *wsHandler) handle(c context.Context) {
ctx, f := context.WithCancel(c)
defer f()
cli, err := pkgssh.DialSshRemote(ctx, w.sshConfig, ctx.Done())
Function createTun
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
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
}
- Read upRead up
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 11 return statements (exceeds 4 allowed). Open
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
Method admissionReviewHandler.handleCreate
has 11 return statements (exceeds 4 allowed). Open
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 {
Method Server.ConnectFork
has 11 return statements (exceeds 4 allowed). Open
Open
func (svr *Server) ConnectFork(req *rpc.ConnectRequest, resp rpc.Daemon_ConnectForkServer) (err error) {
defer func() {
util.InitLoggerForServer(true)
log.SetOutput(svr.LogFile)
config.Debug = false