Showing 333 of 526 total issues
Function GetClient
has 9 return statements (exceeds 4 allowed). Open
func GetClient(isSudo bool) (cli rpc.DaemonClient) {
sockPath := config.GetSockPath(isSudo)
if _, err := os.Stat(sockPath); errors.Is(err, os.ErrNotExist) {
return nil
}
Function runContainer
has 9 return statements (exceeds 4 allowed). Open
func runContainer(ctx context.Context, dockerCli command.Cli, runConfig *RunConfig) error {
config := runConfig.config
stdout, stderr := dockerCli.Out(), dockerCli.Err()
apiClient := dockerCli.Client()
Method admissionReviewHandler.handleCreate
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func (h *admissionReviewHandler) handleCreate(ar v1.AdmissionReview) *v1.AdmissionResponse {
raw := ar.Request.Object.Raw
pod := corev1.Pod{}
deserializer := codecs.UniversalDeserializer()
if _, _, err := deserializer.Decode(raw, nil, &pod); 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
Function createTun
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. 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
}
- 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 Options.Dev
has 9 return statements (exceeds 4 allowed). Open
func (option *Options) Dev(ctx context.Context, cConfig *Config, hostConfig *HostConfig) error {
templateSpec, err := option.GetPodTemplateSpec()
if err != nil {
return err
}
Method Server.Get
has 9 return statements (exceeds 4 allowed). Open
func (svr *Server) Get(ctx context.Context, req *rpc.GetRequest) (*rpc.GetResponse, error) {
if svr.connect == nil || svr.connect.Context() == nil {
return nil, errors.New("not connected")
}
if svr.resourceLists == nil {
Method Krb5InitiatorClient.InitSecContext
has 9 return statements (exceeds 4 allowed). Open
func (k *Krb5InitiatorClient) InitSecContext(target string, token []byte, isGSSDelegCreds bool) ([]byte, bool, error) {
GSSAPIFlags := []int{
ContextFlagREADY,
gssapi.ContextFlagInteg,
gssapi.ContextFlagMutual,
Function PortMapUntil
has 9 return statements (exceeds 4 allowed). Open
func PortMapUntil(ctx context.Context, conf *SshConfig, remote, local netip.AddrPort) error {
// Listen on remote server port
var lc net.ListenConfig
localListen, e := lc.Listen(ctx, "tcp", local.String())
if e != nil {
Method SvrOption.detectUnixSocksFile
has 9 return statements (exceeds 4 allowed). Open
func (o *SvrOption) detectUnixSocksFile(ctx context.Context) {
var f = func() {
_, err := os.Stat(config.GetSockPath(o.IsSudo))
if errors.Is(err, os.ErrNotExist) {
o.Stop()
Method server.ServeDNS
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. 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)
- 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.removeHosts
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func (c *Config) removeHosts(hosts []Entry) error {
if len(hosts) == 0 {
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 networkSetup
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func networkSetup(ip string, namespace string) {
networkCancel()
b, err := exec.Command("networksetup", "-listallnetworkservices").Output()
if err != nil {
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 GetKubeconfigPath
has 8 return statements (exceeds 4 allowed). Open
func GetKubeconfigPath(factory cmdutil.Factory) (string, error) {
rawConfig, err := factory.ToRawKubeConfigLoader().RawConfig()
if err != nil {
return "", err
}
Function CmdDisconnect
has 8 return statements (exceeds 4 allowed). Open
func CmdDisconnect(f cmdutil.Factory) *cobra.Command {
var all = false
var clusterIDs []string
cmd := &cobra.Command{
Use: "disconnect",
Function newer
has 8 return statements (exceeds 4 allowed). Open
func newer(clientImgStr, serverImgStr string) (bool, error) {
clientImg, err := reference.ParseNormalizedNamed(clientImgStr)
if err != nil {
return false, err
}
Function CreateAfterDeletePod
has 8 return statements (exceeds 4 allowed). Open
func CreateAfterDeletePod(factory util.Factory, p *v1.Pod, helper *resource.Helper) error {
_, err := helper.DeleteWithOptions(p.Namespace, p.Name, &v12.DeleteOptions{
GracePeriodSeconds: pointer.Int64(0),
})
if err != nil {
Method CloneOptions.replaceRegistry
has 8 return statements (exceeds 4 allowed). Open
func (d *CloneOptions) replaceRegistry(u *unstructured.Unstructured) error {
// not pass this options, do nothing
if !d.IsChangeTargetRegistry {
return nil
}
Function Complete
has 8 return statements (exceeds 4 allowed). Open
func Complete(ctx context.Context, route *core.Route) error {
if v, ok := os.LookupEnv(config.EnvInboundPodTunIPv4); !ok || v != "" {
return nil
}
Method Manager.ForEach
has 8 return statements (exceeds 4 allowed). Open
func (m *Manager) ForEach(ctx context.Context, fnv4 func(net.IP), fnv6 func(net.IP)) error {
cm, err := m.client.Get(ctx, config.ConfigMapPodTrafficManager, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("failed to get cm DHCP server, err: %v", err)
}
Method Options.Main
has 8 return statements (exceeds 4 allowed). Open
func (option *Options) Main(ctx context.Context, sshConfig *pkgssh.SshConfig, flags *pflag.FlagSet, transferImage bool) error {
mode := typescontainer.NetworkMode(option.ContainerOptions.netMode.NetworkMode())
if mode.IsContainer() {
log.Infof("Network mode container is %s", mode.ConnectedContainer())
inspect, err := option.cli.ContainerInspect(ctx, mode.ConnectedContainer())