Showing 333 of 526 total issues
Method CCache.Marshal
has 8 return statements (exceeds 4 allowed). Open
func (c *CCache) Marshal() ([]byte, error) {
var b bytes.Buffer
var err error
endian := c.getEndian()
Method Route.GenerateServers
has 8 return statements (exceeds 4 allowed). 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
Method CloneOptions.Cleanup
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (d *CloneOptions) Cleanup(workloads ...string) error {
if len(workloads) == 0 {
workloads = d.Workloads
}
for _, workload := range workloads {
- 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 Connects.Less
has 7 return statements (exceeds 4 allowed). Open
func (s Connects) Less(i, j int) bool {
a := s[i]
b := s[j]
if a == nil {
Function GetVolume
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. 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
}
- 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 attachContainer
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func attachContainer(ctx context.Context, dockerCli command.Cli, containerID string, errCh *chan error, config *container.Config, options container.AttachOptions) (func(), error) {
Avoid deeply nested control flow statements. Open
} else if err != nil {
return err
}
Function genOutput
has 7 return statements (exceeds 4 allowed). Open
func genOutput(status *rpc.StatusResponse, format string) (string, error) {
switch format {
case FormatJson:
if len(status.List) == 0 {
return "", nil
Avoid deeply nested control flow statements. Open
} else if err != nil {
return err
}
Function GetClusterIDByConfig
has 7 return statements (exceeds 4 allowed). 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{})
Avoid deeply nested control flow statements. Open
if len(comps) > 0 && len(toComplete) > 0 {
if files, err := os.ReadDir("."); err == nil {
for _, file := range files {
filename := file.Name()
if strings.HasPrefix(filename, toComplete) {
Function InjectVPNSidecar
has 7 return statements (exceeds 4 allowed). Open
func InjectVPNSidecar(ctx1 context.Context, factory util.Factory, namespace, workload string, c util2.PodRouteConfig) error {
object, err := util2.GetUnstructuredObject(factory, namespace, workload)
if err != nil {
return err
}
Function ConvertToKubeConfigBytes
has 7 return statements (exceeds 4 allowed). Open
func ConvertToKubeConfigBytes(factory cmdutil.Factory) ([]byte, string, error) {
loader := factory.ToRawKubeConfigLoader()
namespace, _, err := loader.Namespace()
if err != nil {
return nil, "", err
Function run
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. 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
- 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 CmdStatus
has 7 return statements (exceeds 4 allowed). Open
func CmdStatus(f cmdutil.Factory) *cobra.Command {
var aliasName string
var localFile string
var remoteAddr string
var format string
Function CmdDisconnect
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func CmdDisconnect(f cmdutil.Factory) *cobra.Command {
var all = false
var clusterIDs []string
cmd := &cobra.Command{
Use: "disconnect",
- 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 Parse
has 7 return statements (exceeds 4 allowed). Open
func Parse(flags *pflag.FlagSet, copts *ContainerOptions) (*Config, *HostConfig, error) {
var (
attachStdin = copts.attach.Get("stdin")
attachStdout = copts.attach.Get("stdout")
attachStderr = copts.attach.Get("stderr")
Method ConnectOptions.setupDNS
has 7 return statements (exceeds 4 allowed). Open
func (c *ConnectOptions) setupDNS(ctx context.Context) error {
const port = 53
const portTCP = 10800
pod, err := c.GetRunningPodList(ctx)
if err != nil {
Avoid deeply nested control flow statements. Open
if absHostPart, err := filepath.Abs(hostPart); err == nil {
hostPart = absHostPart
}
Function monitorSize
has 7 return statements (exceeds 4 allowed). Open
func monitorSize(ctx context.Context, sessionID string) error {
conn := daemon.GetTCPClient(true)
if conn == nil {
return fmt.Errorf("conn is nil")
}