Showing 79 of 109 total issues
Function execute
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func execute(method string, url *url.URL, config *restclient.Config, stdin io.Reader, stdout, stderr io.Writer, tty bool) error {
Avoid deeply nested control flow statements. Open
Open
} else if index == 5 {
iface = parts[i]
} else if index > 5 {
iface = fmt.Sprintf("%s %s", iface, parts[i])
}
Function combineKubeOpts
has 7 return statements (exceeds 4 allowed). Open
Open
func combineKubeOpts() (err error) {
var config *clientcmdapi.Config
if opt.Get().Global.Kubeconfig != ""{
// if kubeconfig specified, always read from it
_ = os.Setenv(util.EnvKubeConfig, opt.Get().Global.Kubeconfig)
Avoid deeply nested control flow statements. Open
Open
if _, err = strconv.Atoi(upstreamParts[1]); err == nil {
dnsAddresses = append(dnsAddresses, fmt.Sprintf("udp:%s:%s", upstreamDns, upstreamParts[1]))
} else {
dnsAddresses = append(dnsAddresses, fmt.Sprintf("%s:%s:%d", upstreamParts[0], upstreamDns, common.StandardDnsPort))
}
Avoid deeply nested control flow statements. Open
Open
if keepShortDomain {
recordsToKeep = append(recordsToKeep, l)
}
Avoid deeply nested control flow statements. Open
Open
} else if !strings.HasSuffix(l, midDomain) && !strings.HasSuffix(l, fullDomain) {
recordsToKeep = append(recordsToKeep, l)
}
Function SaveProfile
has 6 return statements (exceeds 4 allowed). Open
Open
func SaveProfile(args []string) error {
if len(args) != 1 {
return fmt.Errorf("must specifiy a profile name")
}
profile := profileFile(args[0])
Function GetServiceByResourceName
has 6 return statements (exceeds 4 allowed). Open
Open
func GetServiceByResourceName(resourceName, namespace string) (*coreV1.Service, error) {
resourceType, name, err := ParseResourceName(resourceName)
if err != nil {
return nil, err
}
Function GetDeploymentByResourceName
has 6 return statements (exceeds 4 allowed). Open
Open
func GetDeploymentByResourceName(resourceName, namespace string) (*appV1.Deployment, error) {
resourceType, name, err := ParseResourceName(resourceName)
if err != nil {
return nil, err
}
Function Mesh
has 6 return statements (exceeds 4 allowed). Open
Open
func Mesh(resourceName string) error {
ch, err := general.SetupProcess(util.ComponentMesh)
if err != nil {
return err
}
Function parsePort
has 6 return statements (exceeds 4 allowed). Open
Open
func parsePort(args []string) (localPort int, remotePort int, err error) {
if len(args) < 2 {
// port not specified
return -1, -1, nil
} else if count := strings.Count(args[1], ":"); count == 0 {
Function Show
has 6 return statements (exceeds 4 allowed). Open
Open
func Show(args []string) error {
if len(args) > 0 {
return fmt.Errorf("parameter '%s' is invalid", args[0])
}
customConfig := loadCustomConfig()
Function NewForwardCommand
has 6 return statements (exceeds 4 allowed). Open
Open
func NewForwardCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "forward",
Short: "Redirect local port to a service or any remote address",
PreRunE: func(cmd *cobra.Command, args []string) error {
Function createRouter
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func createRouter(routerPodName string, svcName string, ports map[int]int, labels map[string]string, versionMark string) error {
Method Kubernetes.waitPodsReady
has 5 return statements (exceeds 4 allowed). Open
Open
func (k *Kubernetes) waitPodsReady(labels map[string]string, namespace string, timeoutSec int, times int) ([]coreV1.Pod, error) {
pods, err := k.GetPodsByLabel(labels, namespace)
if err != nil {
return nil, err
}
Function exchangeWithEphemeralContainer
has 5 return statements (exceeds 4 allowed). Open
Open
func exchangeWithEphemeralContainer(exposePorts string, localSSHPort int, privateKey string) error {
// Get all listened ports on remote host
listenedPorts, err := getListenedPorts(localSSHPort, privateKey)
if err != nil {
return err
Function isPartOfRange
has 5 return statements (exceeds 4 allowed). Open
Open
func isPartOfRange(ipRange string, subIpRange string) bool {
ipRangeBin, err := ipRangeToBin(ipRange)
if err != nil {
return false
}
Function LockService
has 5 return statements (exceeds 4 allowed). Open
Open
func LockService(serviceName, namespace string, times int) (*coreV1.Service, error) {
if times > 10 {
return nil, fmt.Errorf("failed to obtain kt lock of service %s, please try again later", serviceName)
}
svc, err := cluster.Ins().GetService(serviceName, namespace)
Function NewRecoverCommand
has 5 return statements (exceeds 4 allowed). Open
Open
func NewRecoverCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "recover",
Short: "Restore traffic of specified kubernetes service changed by exchange or mesh",
PreRunE: func(cmd *cobra.Command, args []string) error {
Function exposeLocalService
has 5 return statements (exceeds 4 allowed). Open
Open
func exposeLocalService(serviceName, shadowPodName string, labels, annotations map[string]string) error {
envs := make(map[string]string)
_, podName, privateKeyPath, err := cluster.Ins().GetOrCreateShadow(shadowPodName, labels, annotations, envs,
opt.Get().Preview.Expose, map[int]string{})