Showing 526 of 526 total issues
Function ParseAndGet
has 5 return statements (exceeds 4 allowed). Open
Open
func ParseAndGet(localFile, remoteAddr string, aliasName string) ([]Config, error) {
var content []byte
var err error
var path string
if localFile != "" {
Method ConnectOptions.InitClient
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *ConnectOptions) InitClient(f cmdutil.Factory) (err error) {
c.factory = f
if c.config, err = c.factory.ToRESTConfig(); err != nil {
return
}
Function GetAPIServerFromKubeConfigBytes
has 5 return statements (exceeds 4 allowed). Open
Open
func GetAPIServerFromKubeConfigBytes(kubeconfigBytes []byte) *net.IPNet {
kubeConfig, err := clientcmd.RESTConfigFromKubeConfig(kubeconfigBytes)
if err != nil {
return nil
}
Function GetVolume
has 5 return statements (exceeds 4 allowed). 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 quit
has 5 return statements (exceeds 4 allowed). Open
Open
func quit(ctx context.Context, isSudo bool) error {
cli := daemon.GetClient(isSudo)
if cli == nil {
return nil
}
Method ConnectOptions.LeaveProxyResources
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *ConnectOptions) LeaveProxyResources(ctx context.Context) (err error) {
if c == nil || c.clientset == nil {
return
}
Method CloneOptions.setEnv
has 5 return statements (exceeds 4 allowed). Open
Open
func (d *CloneOptions) setEnv(u *unstructured.Unstructured) error {
temp, path, err := util.GetPodTemplateSpecPath(u)
if err != nil {
return err
}
Function NeedsUpgrade
has 5 return statements (exceeds 4 allowed). Open
Open
func NeedsUpgrade(ctx context.Context, client *http.Client, version string) (url string, latestVersion string, upgrade bool, err error) {
latestVersion, url, err = util.GetManifest(client, runtime.GOOS, runtime.GOARCH)
if err != nil {
v := "https://github.com/kubenetworks/kubevpn/raw/master/plugins/stable.txt"
var stream []byte
Function GetNsForListPodAndSvc
has 5 return statements (exceeds 4 allowed). Open
Open
func GetNsForListPodAndSvc(ctx context.Context, clientset *kubernetes.Clientset, nsList []string) (podNs string, svcNs string, err error) {
for _, ns := range nsList {
log.Debugf("List namepsace %s pods", ns)
_, err = clientset.CoreV1().Pods(ns).List(ctx, metav1.ListOptions{Limit: 1})
if apierrors.IsForbidden(err) {
Function CreateFolder
has 5 return statements (exceeds 4 allowed). Open
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 CopyVolumeIntoContainer
has 5 return statements (exceeds 4 allowed). Open
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 runLogsWaitRunning
has 5 return statements (exceeds 4 allowed). Open
Open
func runLogsWaitRunning(ctx context.Context, dockerCli command.Cli, id string) error {
c, err := dockerCli.Client().ContainerInspect(ctx, id)
if err != nil {
return err
}
Function NewOnAddresses
has 5 return statements (exceeds 4 allowed). Open
Open
func NewOnAddresses(dialer httpstream.Dialer, addresses []string, ports []string, stopChan <-chan struct{}, readyChan chan struct{}, out, errOut io.Writer) (*PortForwarder, error) {
if len(addresses) == 0 {
return nil, errors.New("you must specify at least 1 address")
}
parsedAddresses, err := parseAddresses(addresses)
Function cmdConfigAdd
has 5 return statements (exceeds 4 allowed). Open
Open
func cmdConfigAdd(f cmdutil.Factory) *cobra.Command {
var sshConf = &pkgssh.SshConfig{}
cmd := &cobra.Command{
Use: "add",
Short: i18n.T("Proxy kubeconfig"),
Method ConnectOptions.PreCheckResource
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *ConnectOptions) PreCheckResource() error {
if len(c.Workloads) == 0 {
return nil
}
Function parsePorts
has 5 return statements (exceeds 4 allowed). Open
Open
func parsePorts(ports []string) ([]ForwardedPort, error) {
var forwards []ForwardedPort
for _, portString := range ports {
parts := strings.Split(portString, ":")
var localString, remoteString string
Method ConnectOptions.getCIDR
has 5 return statements (exceeds 4 allowed). 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 removeInboundContainer
has 5 return statements (exceeds 4 allowed). Open
Open
func removeInboundContainer(factory util.Factory, namespace, workloads string) error {
object, err := util2.GetUnstructuredObject(factory, namespace, workloads)
if err != nil {
return err
}
Function CmdReset
has 5 return statements (exceeds 4 allowed). Open
Open
func CmdReset(f cmdutil.Factory) *cobra.Command {
var sshConf = &pkgssh.SshConfig{}
cmd := &cobra.Command{
Use: "reset",
Short: "Reset all resource create by kubevpn in k8s cluster",
Function genProxyMsg
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func genProxyMsg(w *tabwriter.Writer, list []*rpc.Status) {
var needsPrint bool
for _, status := range list {
if len(status.ProxyList) != 0 {
needsPrint = true
- 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"