Showing 333 of 526 total issues
Avoid deeply nested control flow statements. Open
Open
} else if err != nil {
return err
}
Method CloneOptions.SyncDir
has 7 return statements (exceeds 4 allowed). Open
Open
func (d *CloneOptions) SyncDir(ctx context.Context, labels string) error {
list, err := util.GetRunningPodList(ctx, d.targetClientset, d.TargetNamespace, labels)
if err != nil {
return err
}
Function NewOnAddresses
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func NewOnAddresses(dialer httpstream.Dialer, addresses []string, ports []string, stopChan <-chan struct{}, readyChan chan struct{}, out, errOut io.Writer) (*PortForwarder, error) {
Method SvrOption.Start
has 7 return statements (exceeds 4 allowed). Open
Open
func (o *SvrOption) Start(ctx context.Context) error {
l := &lumberjack.Logger{
Filename: action.GetDaemonLogPath(),
MaxSize: 100,
MaxAge: 3,
Function TransferImage
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func TransferImage(ctx context.Context, conf *SshConfig, imageSource, imageTarget string, out io.Writer) error {
client, cli, err := GetClient()
if err != nil {
log.Errorf("Failed to get docker client: %v", err)
return 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
Avoid deeply nested control flow statements. Open
Open
if config.Keyfile == "" {
config.Keyfile = filepath.Join(homedir.HomeDir(), ".ssh", "id_rsa")
}
Method CopyOptions.Run
has 7 return statements (exceeds 4 allowed). Open
Open
func (o *CopyOptions) Run() error {
srcSpec, err := extractFileSpec(o.args[0])
if err != nil {
return err
}
Avoid deeply nested control flow statements. Open
Open
if err != nil {
return nil, err
}
Avoid deeply nested control flow statements. Open
Open
} else if lookup.DefValue != "" {
configFlags.KubeConfig = pointer.String(lookup.DefValue)
}
Avoid deeply nested control flow statements. Open
Open
} else if code := status.Code(err); code == codes.AlreadyExists {
return fmt.Errorf("connect with cluster already established, disconnect required before proceeding")
} else {
return err
}
Method Manager.RentIP
has 7 return statements (exceeds 4 allowed). Open
Open
func (m *Manager) RentIP(ctx context.Context) (*net.IPNet, *net.IPNet, error) {
addrs, _ := net.InterfaceAddrs()
var isAlreadyExistedFunc = func(ip net.IP) bool {
for _, addr := range addrs {
if addr == nil {
Function PullImage
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func PullImage(ctx context.Context, platform *v1.Platform, cli *client.Client, dockerCli *command.DockerCli, img string, out io.Writer) error {
Avoid deeply nested control flow statements. Open
Open
} else if err != nil {
log.Errorf("Receive from disconnect failed: %v", err)
return err
}
Avoid deeply nested control flow statements. Open
Open
if err != nil {
return nil, err
}
Avoid deeply nested control flow statements. Open
Open
} else if lookup.DefValue != "" {
path = lookup.DefValue
} else {
path = lookup.NoOptDefVal
}
Avoid deeply nested control flow statements. Open
Open
} else if event.Op&fsnotify.Remove == fsnotify.Remove {
notifyCh <- NotifyMessage{
Operation: Remove,
FilePath: event.Name,
}
Method CCache.writePrincipal
has 7 return statements (exceeds 4 allowed). Open
Open
func (c *CCache) writePrincipal(p principal, endian *binary.ByteOrder) ([]byte, error) {
var byteString bytes.Buffer
var err error
b := &byteString
Function NewTunEndpoint
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func NewTunEndpoint(ctx context.Context, tun net.Conn, mtu uint32, engine config.Engine, in chan<- *DataElem, out chan *DataElem) stack.LinkEndpoint {
Method hijackedIOStreamer.stream
has 7 return statements (exceeds 4 allowed). Open
Open
func (h *hijackedIOStreamer) stream(ctx context.Context) error {
restoreInput, err := h.setupInput()
if err != nil {
return fmt.Errorf("unable to setup input stream: %s", err)
}
Avoid deeply nested control flow statements. Open
Open
if net.ParseIP(svc.Spec.ClusterIP) == nil {
continue
}