kubenetworks/kubevpn

View on GitHub
pkg/inject/proxy.go

Summary

Maintainability
B
5 hrs
Test Coverage

Function InjectVPNSidecar has 68 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func InjectVPNSidecar(ctx1 context.Context, factory util.Factory, namespace, workload string, c util2.PodRouteConfig) error {
    object, err := util2.GetUnstructuredObject(factory, namespace, workload)
    if err != nil {
        return err
    }
Severity: Minor
Found in pkg/inject/proxy.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 CreateAfterDeletePod has 8 return statements (exceeds 4 allowed).
    Open

    func CreateAfterDeletePod(factory util.Factory, p *v1.Pod, helper *resource.Helper) error {
        _, err := helper.DeleteWithOptions(p.Namespace, p.Name, &v12.DeleteOptions{
            GracePeriodSeconds: pointer.Int64(0),
        })
        if err != nil {
    Severity: Major
    Found in pkg/inject/proxy.go - About 50 mins to fix

      Function InjectVPNSidecar has 7 return statements (exceeds 4 allowed).
      Open

      func InjectVPNSidecar(ctx1 context.Context, factory util.Factory, namespace, workload string, c util2.PodRouteConfig) error {
          object, err := util2.GetUnstructuredObject(factory, namespace, workload)
          if err != nil {
              return err
          }
      Severity: Major
      Found in pkg/inject/proxy.go - About 45 mins to fix

        Function fromPatchToProbe has 6 return statements (exceeds 4 allowed).
        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: Major
        Found in pkg/inject/proxy.go - About 40 mins to fix

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

            There are no issues that match your filters.

            Category
            Status