Showing 333 of 526 total issues
Method ConnectOptions.getCIDR
has 5 return statements (exceeds 4 allowed). 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
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
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
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"
Further reading
Method CloneOptions.Cleanup
has 5 return statements (exceeds 4 allowed). Open
func (d *CloneOptions) Cleanup(workloads ...string) error {
if len(workloads) == 0 {
workloads = d.Workloads
}
for _, workload := range workloads {
Function legacyWaitExitOrRemoved
has 5 return statements (exceeds 4 allowed). Open
func legacyWaitExitOrRemoved(ctx context.Context, apiClient client.APIClient, containerID string, waitRemove bool) <-chan int {
var removeErr error
statusChan := make(chan int)
exitCode := 125
Method SshConfig.GetAuth
has 5 return statements (exceeds 4 allowed). Open
func (config SshConfig) GetAuth() ([]ssh.AuthMethod, error) {
host, _, _ := net.SplitHostPort(config.Addr)
var auth []ssh.AuthMethod
var c Krb5InitiatorClient
var err error
Method CCache.Unmarshal
has 5 return statements (exceeds 4 allowed). Open
func (c *CCache) Unmarshal(b []byte) error {
p := 0
//The first byte of the file always has the value 5
if int8(b[p]) != 5 {
return errors.New("Invalid credential cache data. First byte does not equal 5")
Method Server.List
has 5 return statements (exceeds 4 allowed). Open
func (svr *Server) List(ctx context.Context, req *rpc.ListRequest) (*rpc.ListResponse, error) {
if svr.connect == nil || svr.connect.GetClientset() == nil {
return nil, fmt.Errorf("not connect to any cluster")
}
mapInterface := svr.connect.GetClientset().CoreV1().ConfigMaps(svr.connect.Namespace)
Method CCache.writeV4Header
has 5 return statements (exceeds 4 allowed). Open
func (c *CCache) writeV4Header() ([]byte, error) {
var byteString bytes.Buffer
var err error
b := &byteString
Method Client.Call
has 5 return statements (exceeds 4 allowed). Open
func (c *Client) Call(ctx context.Context, uri, method string, body []byte) ([]byte, error) {
var url = path.Join(c.GUIAddress, uri)
req, err := http.NewRequest(method, fmt.Sprintf("http://%s", url), bytes.NewBuffer(body))
if err != nil {
return nil, fmt.Errorf("failed to initialize syncthing API request: %w", err)
Function Main
has 5 return statements (exceeds 4 allowed). Open
func Main(ctx context.Context, filename string, port uint, logger *log.Logger) error {
snapshotCache := cache.NewSnapshotCache(false, cache.IDHash{}, logger)
proc := NewProcessor(snapshotCache, logger)
errChan := make(chan error, 2)
Method Server.Reset
has 5 return statements (exceeds 4 allowed). Open
func (svr *Server) Reset(req *rpc.ResetRequest, resp rpc.Daemon_ResetServer) error {
defer func() {
util.InitLoggerForServer(true)
log.SetOutput(svr.LogFile)
config.Debug = false
Function GetClientWithoutCache
has 5 return statements (exceeds 4 allowed). Open
func GetClientWithoutCache(ctx context.Context, isSudo bool) (cli rpc.DaemonClient, conn *grpc.ClientConn, err error) {
sockPath := config.GetSockPath(isSudo)
_, err = os.Stat(sockPath)
if errors.Is(err, os.ErrNotExist) {
return
Function createTun
has a Cognitive Complexity of 22 (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.CreateConnectContainer
has 5 return statements (exceeds 4 allowed). Open
func (option *Options) CreateConnectContainer(portBindings nat.PortMap) (*RunConfig, error) {
portMap, portSet, err := option.GetExposePort(portBindings)
if err != nil {
return nil, err
}
Function runDaemon
has 5 return statements (exceeds 4 allowed). Open
func runDaemon(ctx context.Context, exe string, isSudo bool) error {
cli := GetClient(isSudo)
if cli != nil {
return nil
}
Function Main
has 5 return statements (exceeds 4 allowed). Open
func Main(f util.Factory) error {
clientset, err := f.KubernetesClientSet()
if err != nil {
return err
}
Method SvrOption.detectUnixSocksFile
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. 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()
- 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 Processor.ProcessFile
has 5 return statements (exceeds 4 allowed). Open
func (p *Processor) ProcessFile(file NotifyMessage) error {
configList, err := ParseYaml(file.FilePath)
if err != nil {
p.logger.Errorf("error parsing yaml file: %+v", err)
return err