kubenetworks/kubevpn

View on GitHub
pkg/util/volume.go

Summary

Maintainability
B
4 hrs
Test Coverage

Function GetVolume has 51 lines of code (exceeds 50 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
    }
Severity: Minor
Found in pkg/util/volume.go - About 1 hr to fix

    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
        }
    Severity: Minor
    Found in pkg/util/volume.go - About 45 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 CreateFolder has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    func CreateFolder(ctx context.Context, cli *client.Client, id string, src string, target string) (string, error) {
    Severity: Minor
    Found in pkg/util/volume.go - About 35 mins to fix

      Function GetVolume has 5 return statements (exceeds 4 allowed).
      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
          }
      Severity: Major
      Found in pkg/util/volume.go - About 35 mins to fix

        Function CreateFolder has 5 return statements (exceeds 4 allowed).
        Open

        func CreateFolder(ctx context.Context, cli *client.Client, id string, src string, target string) (string, error) {
            lstat, err := os.Lstat(src)
            if err != nil {
                return "", err
            }
        Severity: Major
        Found in pkg/util/volume.go - About 35 mins to fix

          Function CopyVolumeIntoContainer has 5 return statements (exceeds 4 allowed).
          Open

          func CopyVolumeIntoContainer(ctx context.Context, volume []mount.Mount, cli *client.Client, id string) error {
              // copy volume into container
              for _, v := range volume {
                  target, err := CreateFolder(ctx, cli, id, v.Source, v.Target)
                  if err != nil {
          Severity: Major
          Found in pkg/util/volume.go - About 35 mins to fix

            There are no issues that match your filters.

            Category
            Status