Showing 333 of 526 total issues
Function UDPForwarder
has 62 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func UDPForwarder(s *stack.Stack) func(id stack.TransportEndpointID, pkt *stack.PacketBuffer) bool {
GvisorUDPForwardAddr := GvisorUDPForwardAddr
return udp.NewForwarder(s, func(request *udp.ForwarderRequest) {
endpointID := request.ID()
log.Debugf("[TUN-UDP] LocalPort: %d, LocalAddress: %s, RemotePort: %d, RemoteAddress %s",
Function CmdDaemon
has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring. Open
Open
func CmdDaemon(_ cmdutil.Factory) *cobra.Command {
var opt = &daemon.SvrOption{}
cmd := &cobra.Command{
Use: "daemon",
Short: i18n.T("Startup kubevpn daemon server"),
- 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 ConvertK8sApiServerToDomain
has 15 return statements (exceeds 4 allowed). Open
Open
func ConvertK8sApiServerToDomain(kubeConfigPath string) (newPath string, err error) {
var kubeConfigBytes []byte
kubeConfigBytes, err = os.ReadFile(kubeConfigPath)
if err != nil {
return
Method Manager.updateDHCPConfigMap
has 15 return statements (exceeds 4 allowed). 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 createTun
has 15 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
}
Function CmdCp
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func CmdCp(f cmdutil.Factory) *cobra.Command {
o := cp.NewCopyOptions(genericiooptions.IOStreams{
In: os.Stdin,
Out: os.Stdout,
ErrOut: os.Stderr,
Function recursiveTar
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func recursiveTar(srcDir, srcFile localPath, destDir, destFile remotePath, tw *tar.Writer) error {
matchedPaths, err := srcDir.Join(srcFile).Glob()
if err != nil {
return err
}
Method ConnectOptions.getCIDR
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *ConnectOptions) getCIDR(ctx context.Context, m *dhcp.Manager) (err error) {
defer func() {
if err == nil {
u, err2 := url.Parse(c.config.Host)
if err2 != nil {
Function CmdConnect
has 14 return statements (exceeds 4 allowed). Open
Open
func CmdConnect(f cmdutil.Factory) *cobra.Command {
var connect = &handler.ConnectOptions{}
var extraRoute = &handler.ExtraRouteInfo{}
var sshConf = &pkgssh.SshConfig{}
var transferImage, foreground, lite bool
Function recursiveTar
has 14 return statements (exceeds 4 allowed). Open
Open
func recursiveTar(srcDir, srcFile localPath, destDir, destFile remotePath, tw *tar.Writer) error {
matchedPaths, err := srcDir.Join(srcFile).Glob()
if err != nil {
return err
}
Function createTun
has 14 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
}
Function createTun
has 58 lines of code (exceeds 50 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
}
Method Route.GenerateServers
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (r *Route) GenerateServers() ([]Server, error) {
chain, err := r.parseChain()
if err != nil && !errors.Is(err, ErrorInvalidNode) {
log.Errorf("Failed to parse chain: %v", err)
return nil, err
Function createContainer
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func createContainer(ctx context.Context, dockerCli command.Cli, runConfig *RunConfig) (string, error) {
config := runConfig.config
hostConfig := runConfig.hostConfig
networkingConfig := runConfig.networkingConfig
var (
Method server.ServeDNS
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s *server) ServeDNS(w miekgdns.ResponseWriter, m *miekgdns.Msg) {
defer w.Close()
if len(m.Question) == 0 {
m.Response = true
_ = w.WriteMsg(m)
Method Connects.Less
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
Open
func (s Connects) Less(i, j int) bool {
a := s[i]
b := s[j]
if a == 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 ConnectOptions.DoConnect
has 13 return statements (exceeds 4 allowed). Open
Open
func (c *ConnectOptions) DoConnect(ctx context.Context, isLite bool) (err error) {
c.ctx, c.cancel = context.WithCancel(ctx)
log.Info("Starting connect")
m := dhcp.NewDHCPManager(c.clientset.CoreV1().ConfigMaps(c.Namespace), c.Namespace)
Method ConnectOptions.upgradeDeploy
has 13 return statements (exceeds 4 allowed). Open
Open
func (c *ConnectOptions) upgradeDeploy(ctx context.Context) error {
deploy, err := c.clientset.AppsV1().Deployments(c.Namespace).Get(ctx, config.ConfigMapPodTrafficManager, metav1.GetOptions{})
if err != nil {
return err
}
Function downloadAndInstall
has 13 return statements (exceeds 4 allowed). Open
Open
func downloadAndInstall(client *http.Client, url string) error {
temp, err := os.CreateTemp("", "*.zip")
if err != nil {
return err
}
Function CmdProxy
has 13 return statements (exceeds 4 allowed). Open
Open
func CmdProxy(f cmdutil.Factory) *cobra.Command {
var connect = handler.ConnectOptions{}
var extraRoute = &handler.ExtraRouteInfo{}
var sshConf = &pkgssh.SshConfig{}
var transferImage, foreground bool