kubenetworks/kubevpn

View on GitHub

Showing 526 of 526 total issues

Function CmdSSH has 10 return statements (exceeds 4 allowed).
Open

func CmdSSH(_ cmdutil.Factory) *cobra.Command {
    var sshConf = &pkgssh.SshConfig{}
    var ExtraCIDR []string
    cmd := &cobra.Command{
        Use:   "ssh",
Severity: Major
Found in cmd/kubevpn/cmds/ssh.go - About 1 hr to fix

    Function CmdDev has 10 return statements (exceeds 4 allowed).
    Open

    func CmdDev(f cmdutil.Factory) *cobra.Command {
        var options = &dev.Options{
            NoProxy:        false,
            ExtraRouteInfo: handler.ExtraRouteInfo{},
        }
    Severity: Major
    Found in cmd/kubevpn/cmds/dev.go - About 1 hr to fix

      Method Server.Clone has 10 return statements (exceeds 4 allowed).
      Open

      func (svr *Server) Clone(req *rpc.CloneRequest, resp rpc.Daemon_CloneServer) (err error) {
          defer func() {
              util.InitLoggerForServer(true)
              log.SetOutput(svr.LogFile)
              config.Debug = false
      Severity: Major
      Found in pkg/daemon/action/clone.go - About 1 hr to fix

        Function run has 10 return statements (exceeds 4 allowed).
        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
        Severity: Major
        Found in pkg/dev/docker_utils.go - About 1 hr to fix

          Method CopyOptions.untarAll has 10 return statements (exceeds 4 allowed).
          Open

          func (o *CopyOptions) untarAll(prefix string, dest localPath, reader io.Reader) error {
              // TODO: use compression here?
              tarReader := tar.NewReader(reader)
              var linkList []tar.Header
              var genDstFilename = func(headerName string) localPath {
          Severity: Major
          Found in pkg/cp/cp.go - About 1 hr to fix

            Function createContainer has 10 return statements (exceeds 4 allowed).
            Open

            func createContainer(ctx context.Context, dockerCli command.Cli, runConfig *RunConfig) (string, error) {
                config := runConfig.config
                hostConfig := runConfig.hostConfig
                networkingConfig := runConfig.networkingConfig
                var (
            Severity: Major
            Found in pkg/dev/docker_utils.go - About 1 hr to fix

              Function createTun has 10 return statements (exceeds 4 allowed).
              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
                  }
              Severity: Major
              Found in pkg/tun/tun_darwin.go - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                            if (ipProtocol == int(layers.IPProtocolUDP) || ipProtocol == int(layers.IPProtocolUDPLite) || ipProtocol == int(layers.IPProtocolTCP)) &&
                                (engine == config.EngineGvisor || (engine == config.EngineMix && (!config.CIDR.Contains(dst) && !config.CIDR6.Contains(dst)))) {
                Severity: Major
                Found in pkg/core/gvisortunendpoint.go - About 1 hr to fix

                  Function fromPatchToProbe has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func fromPatchToProbe(spec *v1.PodTemplateSpec, path []string, patch []P) {
                      // 3 = readiness + liveness + startup
                      if len(patch) != 3*len(spec.Spec.Containers) {
                          log.Debugf("patch not match container num, not restore")
                          return
                  Severity: Minor
                  Found in pkg/inject/proxy.go - About 55 mins to fix

                  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 ExtractSyncthingGUIZipToDir has 9 return statements (exceeds 4 allowed).
                  Open

                  func ExtractSyncthingGUIZipToDir(fs embed.FS, zipPath, targetDir string) error {
                      zipData, err := fs.Open(zipPath)
                      if err != nil {
                          return err
                      }
                  Severity: Major
                  Found in pkg/syncthing/gui.go - About 55 mins to fix

                    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
                        }
                    Severity: Major
                    Found in pkg/daemon/client.go - About 55 mins to fix

                      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()
                      
                      
                      Severity: Major
                      Found in pkg/dev/docker_utils.go - About 55 mins to fix

                        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 {
                        Severity: Minor
                        Found in pkg/webhook/pods.go - About 55 mins to fix

                        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
                            }
                        Severity: Minor
                        Found in pkg/tun/tun_windows.go - About 55 mins to fix

                        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
                            }
                        Severity: Major
                        Found in pkg/dev/options.go - About 55 mins to fix

                          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 {
                          Severity: Major
                          Found in pkg/daemon/action/get.go - About 55 mins to fix

                            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,
                            Severity: Major
                            Found in pkg/ssh/gssapi.go - About 55 mins to fix

                              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 {
                              Severity: Major
                              Found in pkg/ssh/ssh.go - About 55 mins to fix

                                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()
                                Severity: Major
                                Found in pkg/daemon/daemon.go - About 55 mins to fix

                                  Similar blocks of code found in 49 locations. Consider refactoring.
                                  Open

                                  func (x *ListResponse) ProtoReflect() protoreflect.Message {
                                      mi := &file_daemon_proto_msgTypes[34]
                                      if protoimpl.UnsafeEnabled && x != nil {
                                          ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
                                          if ms.LoadMessageInfo() == nil {
                                  Severity: Major
                                  Found in pkg/daemon/rpc/daemon.pb.go and 48 other locations - About 55 mins to fix
                                  pkg/daemon/rpc/daemon.pb.go on lines 63..73
                                  pkg/daemon/rpc/daemon.pb.go on lines 194..204
                                  pkg/daemon/rpc/daemon.pb.go on lines 250..260
                                  pkg/daemon/rpc/daemon.pb.go on lines 332..342
                                  pkg/daemon/rpc/daemon.pb.go on lines 379..389
                                  pkg/daemon/rpc/daemon.pb.go on lines 426..436
                                  pkg/daemon/rpc/daemon.pb.go on lines 496..506
                                  pkg/daemon/rpc/daemon.pb.go on lines 669..679
                                  pkg/daemon/rpc/daemon.pb.go on lines 716..726
                                  pkg/daemon/rpc/daemon.pb.go on lines 763..773
                                  pkg/daemon/rpc/daemon.pb.go on lines 808..818
                                  pkg/daemon/rpc/daemon.pb.go on lines 848..858
                                  pkg/daemon/rpc/daemon.pb.go on lines 895..905
                                  pkg/daemon/rpc/daemon.pb.go on lines 942..952
                                  pkg/daemon/rpc/daemon.pb.go on lines 998..1008
                                  pkg/daemon/rpc/daemon.pb.go on lines 1113..1123
                                  pkg/daemon/rpc/daemon.pb.go on lines 1199..1209
                                  pkg/daemon/rpc/daemon.pb.go on lines 1280..1290
                                  pkg/daemon/rpc/daemon.pb.go on lines 1374..1384
                                  pkg/daemon/rpc/daemon.pb.go on lines 1454..1464
                                  pkg/daemon/rpc/daemon.pb.go on lines 1494..1504
                                  pkg/daemon/rpc/daemon.pb.go on lines 1544..1554
                                  pkg/daemon/rpc/daemon.pb.go on lines 1605..1615
                                  pkg/daemon/rpc/daemon.pb.go on lines 1652..1662
                                  pkg/daemon/rpc/daemon.pb.go on lines 1699..1709
                                  pkg/daemon/rpc/daemon.pb.go on lines 1746..1756
                                  pkg/daemon/rpc/daemon.pb.go on lines 1794..1804
                                  pkg/daemon/rpc/daemon.pb.go on lines 1849..1859
                                  pkg/daemon/rpc/daemon.pb.go on lines 1903..1913
                                  pkg/daemon/rpc/daemon.pb.go on lines 1950..1960
                                  pkg/daemon/rpc/daemon.pb.go on lines 1995..2005
                                  pkg/daemon/rpc/daemon.pb.go on lines 2036..2046
                                  pkg/daemon/rpc/daemon.pb.go on lines 2090..2100
                                  pkg/daemon/rpc/daemon.pb.go on lines 2135..2145
                                  pkg/daemon/rpc/daemon.pb.go on lines 2223..2233
                                  pkg/daemon/rpc/daemon.pb.go on lines 2277..2287
                                  pkg/daemon/rpc/daemon.pb.go on lines 2324..2334
                                  pkg/daemon/rpc/daemon.pb.go on lines 2371..2381
                                  pkg/daemon/rpc/daemon.pb.go on lines 2421..2431
                                  pkg/daemon/rpc/daemon.pb.go on lines 2482..2492
                                  pkg/daemon/rpc/daemon.pb.go on lines 2538..2548
                                  pkg/daemon/rpc/daemon.pb.go on lines 2650..2660
                                  pkg/daemon/rpc/daemon.pb.go on lines 2709..2719
                                  pkg/daemon/rpc/daemon.pb.go on lines 2749..2759
                                  pkg/dhcp/rpc/dhcpserver.pb.go on lines 47..57
                                  pkg/dhcp/rpc/dhcpserver.pb.go on lines 102..112
                                  pkg/dhcp/rpc/dhcpserver.pb.go on lines 159..169
                                  pkg/dhcp/rpc/dhcpserver.pb.go on lines 227..237

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 125.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language