kubenetworks/kubevpn

View on GitHub
pkg/dev/options.go

Summary

Maintainability
D
2 days
Test Coverage

Method Options.Dev has 104 lines of code (exceeds 50 allowed). Consider refactoring.
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 3 hrs to fix

    Method Options.Dev has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
    Open

    func (option *Options) Dev(ctx context.Context, cConfig *Config, hostConfig *HostConfig) error {
        templateSpec, err := option.GetPodTemplateSpec()
        if err != nil {
            return err
        }
    Severity: Minor
    Found in pkg/dev/options.go - About 3 hrs 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.Connect has 87 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (option *Options) Connect(ctx context.Context, sshConfig *pkgssh.SshConfig, transferImage bool, portBindings nat.PortMap) error {
        switch option.ConnectMode {
        case ConnectModeHost:
            daemonCli := daemon.GetClient(false)
            if daemonCli == nil {
    Severity: Major
    Found in pkg/dev/options.go - About 2 hrs to fix

      Method Options.Connect has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
      Open

      func (option *Options) Connect(ctx context.Context, sshConfig *pkgssh.SshConfig, transferImage bool, portBindings nat.PortMap) error {
          switch option.ConnectMode {
          case ConnectModeHost:
              daemonCli := daemon.GetClient(false)
              if daemonCli == nil {
      Severity: Minor
      Found in pkg/dev/options.go - About 2 hrs 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.CreateConnectContainer has 77 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (option *Options) CreateConnectContainer(portBindings nat.PortMap) (*RunConfig, error) {
          portMap, portSet, err := option.GetExposePort(portBindings)
          if err != nil {
              return nil, err
          }
      Severity: Major
      Found in pkg/dev/options.go - About 2 hrs to fix

        Method Options.Connect has 12 return statements (exceeds 4 allowed).
        Open

        func (option *Options) Connect(ctx context.Context, sshConfig *pkgssh.SshConfig, transferImage bool, portBindings nat.PortMap) error {
            switch option.ConnectMode {
            case ConnectModeHost:
                daemonCli := daemon.GetClient(false)
                if daemonCli == nil {
        Severity: Major
        Found in pkg/dev/options.go - About 1 hr to fix

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

              Method Options.InitClient has 6 return statements (exceeds 4 allowed).
              Open

              func (option *Options) InitClient(f cmdutil.Factory) (err error) {
                  option.factory = f
                  if option.config, err = option.factory.ToRESTConfig(); err != nil {
                      return
                  }
              Severity: Major
              Found in pkg/dev/options.go - About 40 mins to fix

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

                  There are no issues that match your filters.

                  Category
                  Status