Showing 333 of 526 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 {
Function SCP
has 5 return statements (exceeds 4 allowed). Open
func SCP(client *ssh.Client, stdout, stderr io.Writer, filename, to string) error {
file, err := os.Open(filename)
if err != nil {
return err
}
Method Config.usingResolver
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (c *Config) usingResolver(ctx context.Context) {
var clientConfig = c.Config
var ns = c.Ns
path := "/etc/resolver"
- 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 heartbeats
has 5 return statements (exceeds 4 allowed). Open
func heartbeats(ctx context.Context, tun net.Conn) {
conn, err := util.GetTunDeviceByConn(tun)
if err != nil {
log.Errorf("Failed to get tun device: %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
}
Method Config.SetupDNS
has 5 return statements (exceeds 4 allowed). Open
func (c *Config) SetupDNS(ctx context.Context) error {
config := c.Config
tunName := c.TunName
log.Debugf("Setting up DNS...")
// TODO consider use https://wiki.debian.org/NetworkManager and nmcli to config DNS
Method Config.watchServiceToAddHosts
has 5 return statements (exceeds 4 allowed). Open
func (c *Config) watchServiceToAddHosts(ctx context.Context, serviceInterface v13.ServiceInterface, hosts []Entry) {
ticker := time.NewTicker(time.Second * 15)
defer ticker.Stop()
immediate := make(chan struct{}, 1)
immediate <- struct{}{}
Method Config.generateAppendHosts
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (c *Config) generateAppendHosts(serviceList []v12.Service, hosts []Entry) []Entry {
const ServiceKubernetes = "kubernetes"
var entryList = sets.New[Entry]().Insert(c.Hosts...).Insert(hosts...).UnsortedList()
// 1) add only if not exist
- 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 CleanupHosts
has 5 return statements (exceeds 4 allowed). Open
func CleanupHosts() error {
path := GetHostFile()
content, err2 := os.ReadFile(path)
if err2 != nil {
return err2
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 := config.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
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 {
- 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, ns string) {
networkSetup(ip, ns)
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"