Showing 333 of 526 total issues
Method wsHandler.installKubevpnOnRemote
has 11 return statements (exceeds 4 allowed). Open
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))
}
Method Server.Status
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
Open
func (svr *Server) Status(ctx context.Context, req *rpc.StatusRequest) (*rpc.StatusResponse, error) {
var list []*rpc.Status
if len(req.ClusterIDs) != 0 {
for _, clusterID := range req.ClusterIDs {
- 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 GetClusterIDByConfig
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func GetClusterIDByConfig(cmd *cobra.Command, config Config) (string, error) {
flags := flag.NewFlagSet("", flag.ContinueOnError)
var sshConf = &pkgssh.SshConfig{}
pkgssh.AddSshFlags(flags, sshConf)
handler.AddExtraRoute(flags, &handler.ExtraRouteInfo{})
Method CloneOptions.SyncDir
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (d *CloneOptions) SyncDir(ctx context.Context, labels string) error {
list, err := util.GetRunningPodList(ctx, d.targetClientset, d.TargetNamespace, labels)
if err != nil {
return err
}
Function GetClient
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func GetClient(isSudo bool) (cli rpc.DaemonClient) {
sockPath := config.GetSockPath(isSudo)
if _, err := os.Stat(sockPath); errors.Is(err, os.ErrNotExist) {
return nil
}
Method CopyOptions.untarAll
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (o *CopyOptions) untarAll(prefix string, dest localPath, reader io.Reader) error {
// TODO: use compression here?
tarReader := tar.NewReader(reader)
var linkList []tar.Header
var genDstFilename = func(headerName string) localPath {
Method Config.removeHosts
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *Config) removeHosts(hosts []Entry) error {
if len(hosts) == 0 {
return nil
}
Function GetVolume
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func GetVolume(ctx context.Context, f util.Factory, ns, podName string) (map[string][]mount.Mount, error) {
clientSet, err := f.KubernetesClientSet()
if err != nil {
return nil, err
}
Function CmdClone
has 10 return statements (exceeds 4 allowed). Open
Open
func CmdClone(f cmdutil.Factory) *cobra.Command {
var options = handler.CloneOptions{}
var sshConf = &pkgssh.SshConfig{}
var extraRoute = &handler.ExtraRouteInfo{}
var transferImage bool
Method ConnectOptions.addRouteDynamic
has 10 return statements (exceeds 4 allowed). Open
Open
func (c *ConnectOptions) addRouteDynamic(ctx context.Context) error {
tunName, e := c.GetTunDeviceName()
if e != nil {
return e
}
Function CmdSSH
has 10 return statements (exceeds 4 allowed). Open
Open
func CmdSSH(_ cmdutil.Factory) *cobra.Command {
var sshConf = &pkgssh.SshConfig{}
var ExtraCIDR []string
cmd := &cobra.Command{
Use: "ssh",
Function CmdDev
has 10 return statements (exceeds 4 allowed). Open
Open
func CmdDev(f cmdutil.Factory) *cobra.Command {
var options = &dev.Options{
NoProxy: false,
ExtraRouteInfo: handler.ExtraRouteInfo{},
}
Method Server.Clone
has 10 return statements (exceeds 4 allowed). Open
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
Function run
has 10 return statements (exceeds 4 allowed). Open
Open
func run(ctx context.Context, cli *client.Client, dockerCli *command.DockerCli, runConfig *RunConfig) (id string, err error) {
rand.New(rand.NewSource(time.Now().UnixNano()))
var config = runConfig.config
var hostConfig = runConfig.hostConfig
Method CopyOptions.untarAll
has 10 return statements (exceeds 4 allowed). Open
Open
func (o *CopyOptions) untarAll(prefix string, dest localPath, reader io.Reader) error {
// TODO: use compression here?
tarReader := tar.NewReader(reader)
var linkList []tar.Header
var genDstFilename = func(headerName string) localPath {
Function createContainer
has 10 return statements (exceeds 4 allowed). Open
Open
func createContainer(ctx context.Context, dockerCli command.Cli, runConfig *RunConfig) (string, error) {
config := runConfig.config
hostConfig := runConfig.hostConfig
networkingConfig := runConfig.networkingConfig
var (
Function createTun
has 10 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
}
Consider simplifying this complex logical expression. Open
Open
if (ipProtocol == int(layers.IPProtocolUDP) || ipProtocol == int(layers.IPProtocolUDPLite) || ipProtocol == int(layers.IPProtocolTCP)) &&
(engine == config.EngineGvisor || (engine == config.EngineMix && (!config.CIDR.Contains(dst) && !config.CIDR6.Contains(dst)))) {
Function fromPatchToProbe
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
Open
func fromPatchToProbe(spec *v1.PodTemplateSpec, path []string, patch []P) {
// 3 = readiness + liveness + startup
if len(patch) != 3*len(spec.Spec.Containers) {
log.Debugf("patch not match container num, not restore")
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 ExtractSyncthingGUIZipToDir
has 9 return statements (exceeds 4 allowed). Open
Open
func ExtractSyncthingGUIZipToDir(fs embed.FS, zipPath, targetDir string) error {
zipData, err := fs.Open(zipPath)
if err != nil {
return err
}