Showing 358 of 556 total issues
Method admissionReviewHandler.handleDelete
has 5 return statements (exceeds 4 allowed). Open
func (h *admissionReviewHandler) handleDelete(ar v1.AdmissionReview) *v1.AdmissionResponse {
raw := ar.Request.OldObject.Raw
pod := corev1.Pod{}
deserializer := codecs.UniversalDeserializer()
if _, _, err := deserializer.Decode(raw, nil, &pod); err != nil {
Method Server.Reset
has 5 return statements (exceeds 4 allowed). Open
func (svr *Server) Reset(req *rpc.ResetRequest, resp rpc.Daemon_ResetServer) error {
defer func() {
log.SetOutput(svr.LogFile)
log.SetLevel(log.DebugLevel)
}()
Function CreateFolder
has 5 return statements (exceeds 4 allowed). Open
func CreateFolder(ctx context.Context, cli *client.Client, id string, src string, target string) (string, error) {
lstat, err := os.Lstat(src)
if err != nil {
return "", err
}
Function GetManifest
has 5 return statements (exceeds 4 allowed). Open
func GetManifest(httpCli *http.Client, os string, arch string) (version string, commit string, url string, err error) {
var resp *http.Response
var errs []error
for _, addr := range address {
resp, err = httpCli.Get(addr)
Function init
has 5 return statements (exceeds 4 allowed). Open
func init() {
http.Handle("/ws", websocket.Handler(func(conn *websocket.Conn) {
sshConfig := util.SshConfig{
Addr: conn.Request().Header.Get("ssh-addr"),
User: conn.Request().Header.Get("ssh-username"),
Function CopyVolumeIntoContainer
has 5 return statements (exceeds 4 allowed). Open
func CopyVolumeIntoContainer(ctx context.Context, volume []mount.Mount, cli *client.Client, id string) error {
// copy volume into container
for _, v := range volume {
target, err := CreateFolder(ctx, cli, id, v.Source, v.Target)
if err != nil {
Function heartbeats
has 5 return statements (exceeds 4 allowed). Open
func heartbeats(ctx context.Context, tun net.Conn, in chan<- *DataElem) {
conn, err := util.GetTunDeviceByConn(tun)
if err != nil {
log.Errorf("get tun device error: %s", err.Error())
return
Method tcpKeepAliveListener.Accept
has 5 return statements (exceeds 4 allowed). Open
func (ln *tcpKeepAliveListener) Accept() (c net.Conn, err error) {
conn, err := ln.AcceptTCP()
if err != nil {
return
}
Function GetClientWithoutCache
has 5 return statements (exceeds 4 allowed). Open
func GetClientWithoutCache(ctx context.Context, isSudo bool) (cli rpc.DaemonClient, conn *grpc.ClientConn, err error) {
sockPath := GetSockPath(isSudo)
_, err = os.Stat(sockPath)
if errors.Is(err, os.ErrNotExist) {
return
Method SvrOption.detectUnixSocksFile
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (o *SvrOption) detectUnixSocksFile(ctx context.Context) {
var f = func() {
_, err := os.Stat(GetSockPath(o.IsSudo))
if errors.Is(err, os.ErrNotExist) {
o.Stop()
- 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.List
has 5 return statements (exceeds 4 allowed). Open
func (svr *Server) List(ctx context.Context, req *rpc.ListRequest) (*rpc.ListResponse, error) {
if svr.connect == nil || svr.connect.GetClientset() == nil {
return nil, fmt.Errorf("not connect to any cluster")
}
mapInterface := svr.connect.GetClientset().CoreV1().ConfigMaps(svr.connect.Namespace)
Function runDaemon
has 5 return statements (exceeds 4 allowed). Open
func runDaemon(ctx context.Context, exe string, isSudo bool) error {
cli := GetClient(isSudo)
if cli != nil {
return nil
}
Function CleanupHosts
has 5 return statements (exceeds 4 allowed). Open
func CleanupHosts() error {
path := GetHostFile()
content, err := os.ReadFile(path)
if err != nil {
return err
Function DialSshRemote
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
func DialSshRemote(ctx context.Context, conf *SshConfig) (remote *ssh.Client, err error) {
defer func() {
if err != nil {
if remote != nil {
remote.Close()
- 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 parseSecurityOpts
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
func parseSecurityOpts(securityOpts []string) ([]string, error) {
for key, opt := range securityOpts {
k, v, ok := strings.Cut(opt, "=")
if !ok && k != "no-new-privileges" {
k, v, ok = strings.Cut(opt, ":")
- 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 gen
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
func gen(connect *handler.ConnectOptions, clone *handler.CloneOptions) ([]*rpc.Proxy, []*rpc.Clone, error) {
var proxyList []*rpc.Proxy
if connect != nil && connect.GetClientset() != nil {
mapInterface := connect.GetClientset().CoreV1().ConfigMaps(connect.Namespace)
configMap, err := mapInterface.Get(context.Background(), config.ConfigMapPodTrafficManager, metav1.GetOptions{})
- 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 GetClient
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
func GetClient(isSudo bool) (cli rpc.DaemonClient) {
sockPath := GetSockPath(isSudo)
if _, err := os.Stat(sockPath); errors.Is(err, os.ErrNotExist) {
return nil
}
- 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 Config.usingNetworkSetup
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
func (c *Config) usingNetworkSetup(ip string, namespace string) {
networkSetup(ip, namespace)
var ctx context.Context
ctx, cancel = context.WithCancel(context.Background())
go func() {
- 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"